Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
271 views
in Technique[技术] by (71.8m points)

html - How to make relative layout add elements in a horizontal direction?

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

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

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...