Setting the position to relative doesnt necessarily dictate order in terms of horzontal vs vertical placing. This is the difference between block level and inline elements.
Block level elements (e.g. div
) display on a new line by default, inline
elements (e.g. span
) appear on the same line, if the available width allows it.
You can see this in effect here
You can override the default display
for elements by setting it in your CSS.
More on Block level elements from MDN
"Block-level" is categorization of HTML (Hypertext Markup Language)
elements, as contrasted with "inline" elements. Block-level elements
may appear only within a element. Their most significant
characteristic is that they typically are formatted with a line break
before and after the element (thereby creating a stand-alone block of
content). That is, they take up the width of their containers.
More on Inline elements
"Inline" is categorization of HTML elements, as contrasted with
"block-level" elements. Inline elements can appear within block-level
or other inline elements. They take up the width of their contents.
The differences between inline and block-level elements include [...] formatting, by default, inline elements do not begin with new line.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…