Is it possible to apply same style to element 1 and element 2, without calling out the style in element 1?
Element 1 is .notch
Element 2 is #fullbg
Element 1 must always come before Element 2. I would like to apply Element 2's bg-color to Element 1 and Element 2.
How do I make the first <div class="notch">
have a yellow bg (#fullbg), without applying any specific style (class/id) to <div class="notch">
?
I'm thinking this could be done with :nth-of-type() selector...? Eventually, I will have several "notches", with <div id="fullbg3">
, <div id="fullbg4">
, etc.
Check codepen example - I want first notch to be yellow (like fullbg), and second notch to be red (like fullbg2), without giving any notch their own special class.
Currently, the first notch is red. It should be yellow.
http://codepen.io/Goatsy/pen/GqJGxb
HTML
<p>stuff</p>
<div class="notch">this should be YELLOW</div>
<p>stuff</p>
<div id="fullbg">this should be YELLOW</div>
<p>stuff</p>
<div class="notch">this should be RED</div>
<p>stuff</p>
<div id="fullbg2">this should be RED</div>
CSS
.notch,
#fullbg {
background: yellow;
}
.notch,
#fullbg2 {
background: red;
}
Here is, more specifically what I'm trying to achieve: the bgcolor and small block color should match. codepen.io/Goatsy/pen/rLVrJo