Reputation: 3371
My question is simple, but I didn't found any documentation about it on Internet. Maybe I didn't search with the right keywords...
Take the example of a CSS class called centered
, it centers elements and do some other stuff.
I want to say that all the element of the class news
, for example, inherit from centered
.
There is several solutions :
Declare all the elements of centered
in news
.centered { X; Y; Z }
.news { X; Y; Z; A; B }
Declare in HTML my tags with the 2 classes :
.centered { X; Y; Z }
.news { A; B }
<div class="news centered">...</div>
I search a code for doing something like this :
.centered { X; Y; Z }
.news { all_the_properties_of_centered; A; B }
then I would declare my news with
<div class="news">...</div>
Is it possible ?
Upvotes: 2
Views: 145
Reputation: 15749
I suggest to use Emmet, which was previously known as Zen coding for such combinations. It is fast and very productive if constructed logically.
Upvotes: 0
Reputation: 32912
No. CSS doesn't have anything like extend
. However, you can write it this way
.centered, .news { X; Y; Z }
.news { A; B } /* adding rules */
Well, actually it does contain inherit
, but it doesn't mean to inherit from another CSS class, but from default element style, see Hanky Panky's comment.
Upvotes: 1
Reputation: 46900
Simplest way would be
.centered, .news { X; Y; Z }
.news { A; B }
Upvotes: 1