如何使相对布局在水平方向添加元素? [英] How to make relative layout add elements in a horizontal direction?

查看:216
本文介绍了如何使相对布局在水平方向添加元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在列中垂直添加相对元素。是否可以使元素水平而不是垂直显示?

解决方案

将位置设置为relative不一定指示horzontal与垂直放置的顺序。这是块级和内联元素之间的区别。



块级元素(例如 div 默认情况下,如果可用宽度允许, inline 元素(例如 span )出现在同一行。 / p>

您可以在 效果 strong>



您可以通过在CSS中设置元素来覆盖默认 display



更多关于来自MDN的块级元素


块级标记语言)
元素,与内联元素形成对比。块级元素
可能只出现在一个元素内。他们最重要的
特性是它们通常在元素之前和之后用换行符
格式化(从而创建一个独立的
内容块)。也就是说,它们占用了容器的宽度。


内嵌元素的详情


Inline是HTML元素的分类,与
块级元素形成对比。内联元素可以出现在块级别的
或其他内联元素中。他们占据了他们的内容的宽度。
内联和块级元素之间的区别包括[...]格式化,默认情况下,内联元素不以新行开头。



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.

解决方案

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.

这篇关于如何使相对布局在水平方向添加元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆