If have a style like this:
.Style1
{
background-color:white;
}
And a second style like this:
.Style2
{
border: black solid 1px;
}
How do I get Style2
to have Style1
as a base style?
Malcolm
If have a style like this:
.Style1
{
background-color:white;
}
And a second style like this:
.Style2
{
border: black solid 1px;
}
How do I get Style2
to have Style1
as a base style?
Malcolm
There's no inheritance in CSS. The closest you can get to inheritance is by specifying 2 classes in your HTML elements:
<div class="Style1 Style2">..</div>
Or you can simply use the same style name:
.Style1 { background-color:white; }
.Style1 { border: black solid 1px; }
Now Style1 will have both properties
As far as I know, there isn't really a way to do this.
You could of course make whatever element you wish to apply those style to include both class names <div class="style1 style2">
And the lack of this functionality is the reason there's been a rise in OOCSS (Object Oriented CSS). And frameworks such as Less.
You could use
<span class="style1 style2">
or define
span { /* define base styles for all spans here */ }
span.style1 { /*inherits styles from span, and adds specific styles to that */ }
Using with
<p>Normal p text and <span>style</span>, <span class="style1">style 1 type text</span>.</p>
Use this method:
<div class="Style1">
<div class="Style2">bla bla bla</div>
</div>