css selectors - Select last element from already selected elements in pure css -
i want jquery :last
selector, in pure css.
how can 'z' paragraph, if didn't know index in dom structure!. or how last child of class '.area'? see css3 last element , doesnt work in case, because have childs in parent element.
p.area:last-child
donesn't work!
i found solution, when know how many elements class .area
.
selector looks this: p.area ~ p.area ~ p.area
when didn't know ... think... fun =)
<div> <h1>this heading</h1> <p class="">the first paragraph.</p> <p class="area">the x paragraph.</p> <p class="area">the y paragraph.</p> <p class="area">the z paragraph.</p> <p class="">the last paragraph.</p> </div
you cant without javascript. here quote the w3c spec:
standalone text , other non-element nodes not counted when calculating position of element in list of children of parent.
pseudo-classes target elements can't targeted combinators or simple selectors id or class. these types of pseudo classes called "structural pseudo classes". ignore fact there class on element , use dom determine correct element target.
your options explicit targeting nth-child or javascript in instance.
Comments
Post a Comment