dimanche 1 mars 2015

css apply style if parent width more than specific value


Want to apply css selectors if only parent element width more than specific value. CSS must not use media query to implement this because no relation between viewport width and the parent div width.


Javascript is welcome but avoid continuous width check please. Ex.



<style>

/* something like that div[width>400px] */
.parent div[width>400px]{
background:red;
}


</style>


<!--ok width is more than 400 so apply style to child div-->
<div class="parent" style="width:500px;">
<div>

</div>
</div>


<!--width is still less than 400 so don;t apply styles-->
<div class="parent" style="width:300px;">
<div>

</div>
</div>




Aucun commentaire:

Enregistrer un commentaire