Combining position: relative with float in CSS
Posted
by
user74847
on Programmers
See other posts from Programmers
or by user74847
Published on 2014-06-25T05:20:18Z
Indexed on
2014/08/21
16:29 UTC
Read the original article
Hit count: 289
I have always thought of position: relative and float: left as different tools that should be used separately, with some features that overlap. position should be used for positioning things relative to the viewport and float used for floating things within a container.
Today I saw someone combining float: left and position: relative also using top: 10px, when they could have used margin top on the floated element and not added the position relative at all.
It is obviously not wrong to do it in this way because it works, but what is the best practice? Should position relative be used on an element as well as float?
© Programmers or respective owner