I know I can use [dir='ltr']
or [dir='rtl']
to select elements that have a dir attribute with a specific value.
so I can define for example
[dir='ltr'] .float-end {float:right}
[dir='rtl'] .float-end {float:left}
to get a .float-end
class that floats right or left when inside an element with ltr or rtl respectively.
The problem starts when I have an ltr sub part of a document that is rtl.
<div dir="rtl">
<div dir="ltr">
<div class="float-end"></div>
</div>
</div>
What happens is that both rules match... and I only want to match the 'ltr' case in this scenario.
The problem gets worse if I want to create classes such as start-20px
and end-20px
to provide left:20px
and right:20px
and vice versa depending on context.
Would result in both left:20px
and right:20px
being applied....
I am looking for suggestions on how to overcome this.
Is there a way to depend on the nearest value of an attribute of any given type of element?
This is all done within the context of LESS mixins if it helps some how...
Thanks