lundi 4 mai 2015

Css last/deepest match element or attribute to apply a rule that overrides everything prior

For instance,

given

<html dir=rtl> 

<body>

<div>I am right to left</div>
<div>I am right to left
       <div dir=ltr>I should be left to right
       <div dir=rtl>I should be right to left</div></div>
</div>

</body>
</html>

Now I am asking this question because the nested content is generated and there is no way to know priorly how deep this is going to be.

Therefore, ideally a css rule should be able to apply a certain rule based on it's deepest match.

The rule:

[dir=rtl] {
    text-align:right;
}

will only match the first. Ideally, you'd want something like

[dir=rtl]:deepest {
    text-align:right;
}




Aucun commentaire:

Enregistrer un commentaire