What is the most elegant way to check whether an element is in the normal flow using jQuery?
According to the CSS3 specification,
A box belongs to the flow if:
The used value of its ‘display’ is ‘block’, ‘list-item’, ‘table’ or template.
The used value of its ‘float’ is ‘none’.
The used value of its ‘position’ is ‘static’ or ‘relative’.
It is either a child of the flow root or a child of a box that belong to the flow.
Should I just check for all these conditions, or is there a better way?
I doubt theres a better way, but a different way would be:
1) Surround the element with a wrapper
2) Compare height and width of wrapper with wrapped element
For example:
$('#elementToTest').clone().addClass('clone').wrap('<div></div>')
if($('#elementToTest.clone').height()>$('#elementToTest.clone').parent().height()){
//outside the normal flow
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With