4 ms·
I'm losing track of what CSS can do. Do we have inheritance already? Pseudocode of what I mean: .info { font-size: 8px; } .news extends
by TekMol 4y ago
I'm losing track of what CSS can do.
Do we have inheritance already?
Pseudocode of what I mean:
.info {
font-size: 8px;
}
.news extends .info {
color: black;
}
So news are displayed in an 8px black font.
- mock-possum 4y agonope. you've got a couple of options - .info { font-size: 8px; } .news { color: black; } <div class="info news">asdf</div> or maybe .info { font-size: 8px; } .news { color: black; } <div class="news"><p class="info">asdf</p></div> or even .info, .news { font-size: 8px; } .news { color: black; } <div class="news">asdf</div> but you've got to use LESS/SCSS for true 'extends' type functionality. vanilla CSS is more focused on inheritance.
- TekMol 4y agoOut of these, only the last one seems somewhat okish to me. But it would be annoying to add another selector everytime you add a class that uses the rule. If that is all we have, then I will just stick to css variables: :root { --info-font-size: 8px; } .info { font-size: var(--info-font-size); color: grey; } .news { font-size: var(--info-font-size); color: black; }