I understand how positioning works in general when the values of bottom, top, right and left are given in pixels.
bottom: 2px
will put the box 2px above the bottom of the page.- Similarly
top: 2px
will put the box 2 pixel below the top of the page.
Reading another question, I've also come to know that the value 0 is equivalent to 0px, 0em etc because units are not necessary for a zero value.
Question:
What I don't understand is what do the unit-less nonzero value specify? For example, in this demo the bottom is initially set as 0. If I change the value and set it as say bottom:1
or any numerical value like bottom:786
, the green box will be situated as high as possible (that is, just below the rest of the content) without overlapping other content on the page.
So, what do these non zero numerical values for bottom, top, left and right correspond to? How does the browser position these elements when such a value is provided?