So, the spec defines that elements are drawn "in tree order" for in-flow, non-positioned elements of similar block
level or float
status and identical z-index
. This, of course, means those declared last in the HTML markup are drawn on top. But what if we want that order to be reversed for arbitrary children in a particular container?
For instance, say we have an indefinite number of overlapping float
div
s in a parent div
:
__________________________________
| _________________________ |
| | samant| allis| rachael |... |
| |_______|______|_________|... |
|_________________________________|
That we want instead to look like this:
__________________________________
| _________________________ |
| | samantha |lison |chael |... |
| |__________|______|______|... |
|_________________________________|
Is there still no way to achieve this with css alone? If not, what would be the most efficient and safe way to achieve this functionality with javascript for arbitrary child elements?
Questions have been asked previously for similiar functionality, but not specifically for use in a generic sense with an arbitrary number of child elements. See here and here.
maxValue + minValue - currentValue
to each one. – Exemplaryfloat:right
reverses the entire list though, and aligns them to the right side. What if you want them aligned on the left and in the order in which they are declared? That's why an arbitrary solution is needed. Also, my example usesfloat
s but the question considers block-style elements as well. – Catarinacatarrh