How to highlight last div with class="block"
in the following html-structure, if the number of div
with class="block"
is unknown? (With help of css-selectors)
http://codepen.io/Feel_codepen/pen/Ifjzd
There, for example, I can highlight third div.
You can try this using :last-of-type
div.block:last-of-type{
color:yellow;
}
CodepenDemo
Use last-child
:
.main .block:last-child{
background-color:#FCC;
/* Your styles*/
}
CodePen
You could use the :last-child
selector.
More information could be found at http://css-tricks.com/almanac/selectors/l/last-child/
.main .block:last-child {
background-color: yellow;
}
http://codepen.io/anon/pen/vpqad
By using the last-child pseudo class
.block:last-child{
background-color: yellow; /* or some other color */
}
http://www.w3schools.com/cssref/sel_last-child.asp
Try this
.block:last-child
{
background-color:blue;
}
DEMO
And Magic!
.main>div[class=block]:last-child{
background-color:blue;
}
this should do it :P i hope
Try to use
$("div:last-child").addClass("last-child");
With this you can add a css class to the last child of a certain div or element