html - select first element of the same class -
how access first of many grouped element of same class? lets have looks this:
<div class="group"> <div class="element"></div> <div class="element"></div> <div class="element"></div> <div class="element"></div> </div> <div class="group"> <div class="element"></div> <div class="element"></div> <div class="element"></div> <div class="element"></div> </div> <div class="group"> <div class="element"></div> <div class="element"></div> <div class="element"></div> <div class="element"></div> </div>
i change style first element of each group. how can achieved? tried
.group{ .element:first{ ####styles here } }
but doesn't seem work unfortunately(should it?).
use :first-child
.
.group .element:first-child { color: red; }
<div class="group"> <div class="element">test</div> <div class="element">test</div> <div class="element">test</div> <div class="element">test</div> </div> <div class="group"> <div class="element">test</div> <div class="element">test</div> <div class="element">test</div> <div class="element">test</div> </div> <div class="group"> <div class="element">test</div> <div class="element">test</div> <div class="element">test</div> <div class="element">test</div> </div>
Comments
Post a Comment