开发者

Is it possible to embed the properties of one general CSS selector into another more specific class?

I have a general style sheet (general.css) that spans across each page of my site, and more specific style sheets that apply to certain pages. I'd like to take one of the selectors from general.css and embed it into the selectors of my specific sheets.

For example:

(From general.css)

.PrimaryFont {
font-family:"Palatino Linotype", "Book Antiqua", serif; 
text-transform: uppercase;
font-weight: normal; 
 }

(开发者_高级运维From specific.css)

h1 {
   .PrimaryFont;
   font-size: 18pt;
 }

This way, I won't have to mark up my html to death, and, if I choose to change the Primary Font, I will only have to do so in one spot.

I know LESS lets you embed, but since I'm new to CSS I was hoping there was some magical way a third party wasn't necessary.

Thanks!


Nope. CSS doesn't allow for mixins. You need to use something like LESS/SASS or some other CSS meta framework


The best way to do in plain CSS would be just adding extra classes to elements, but as well as being messy that can quickly get excessive. I would really recommend trying out LESS - it is amazingly good to use.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜