开发者

Apply external stylesheet to a particular section

On my website I allow user-generated style sheets to be used. But I don't want those styles to affect the the whole website, just a separate section/div. Is there way to do that, without going through the whole开发者_如何学JAVA custom style sheet and adding my div selector to every css rule? For example if a user has:

a, span{color:white;}
div{padding:10px;}

Right now I have to parse it out and replace to

#mySection a, #mySection span{color:white;}
#mySection div{padding:10px;}


Nope, unfortunately there isn't. There is no CSS equivalent to the <base> tag or similar that would limit the scope of a CSS rule.

You will have to prepend every rule with the element(s) you want to apply them to, or load the user styled content in an iframe.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜