Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Why are relative elements added vertically, in a column. Is it possible to have elements displayed horizontally instead of vertically? Like a row instead of a column.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
269 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...