Is this going to cause me untold grief if I stick it at the top of my stylesheet?
* {position:relative}
I mostly use position :relative in the element when I know the inner element of that element is going to be positioned absolutely. For example If I have two divs and outside div is a static block and elements inside the outer div is going to be positioned absolute relative to the outer div.
position: relative places an element relative to its current position without changing the layout around it, whereas position: absolute places an element relative to its parent's position and changing the layout around it.
As long as you structure your HTML so that the elements follow a logical order that makes sense when rendered without CSS, there is no reason why using absolute positioning should be considered bad practice.
Relative positions are words that describe where objects are in an environment. For example: top, behind, or next to.
Is this going to cause me untold grief if I stick it at the top of my stylesheet?
Yes. You will not be able to work with absolutely positioned elements any more, for example - the absolute positioning will always be relative to the parent element, which is almost never the desired result.
I could imagine there are even more side-effects field of z-index
settings.
Not a good idea IMO.
And no, position: static
is not deprecated, after all, it is the default setting :)
Wildcards can cause performance issues when not used carefully. That would probably not be the case in your example, but it's a bad habit to develop.
But more importantly, it's rare that you can conclusively say you want any behavior to apply to all elements.
With relative positioning, you will at best achieve nothing and at worst create many headaches for yourself trying to troubleshoot things that would normally "just work".
Relative positioning definitely has its uses. Apply it when you need it.
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