本文共 2130 字,大约阅读时间需要 7 分钟。
css中图片左右边距
CSS Margins are used to space around any element, for this we use "margin" property in the CSS.
CSS边距用于在任何元素之间留出空间,为此,我们在CSS中使用“ margin”属性 。
Syntax:
句法:
Element{ margin: length|auto|initial|inherit; }
When two margins are touching each other vertically, they are collapsed. But when they touch horizontally, they do not collapse.
当两个边距垂直相互接触时,它们将被折叠。 但是,当它们水平接触时,它们不会塌陷。
Example:
例:
Some contentSome more content
Output
输出量
They will be 20px apart since vertical margins collapse over one and other. (The spacing will not be the sum of two margins.)
由于垂直边距会彼此重叠,因此相距20px 。 (间距将不是两个边距的总和。)
In CSS you can specify a given side to apply a margin too. The four properties provided for this purpose are,
在CSS中,您也可以指定给定边以应用边距。 为此目的提供的四个属性是:
margin-left
左边距
margin-right
右边距
margin-top
上边距
margin-bottom
底边
Example:
例:
Some content
Output
输出量
CSS has properties that can be set to negative values. This property can be used to overlap elements without absolute positioning.
CSS具有可以设置为负值的属性。 此属性可用于重叠元素而无需绝对定位。
Example:
例:
Some content
Output
输出量
Here the shorthand is used to specify margin in every direction without writing for every direction.
在这里,速记用于指定每个方向上的边距,而无需为每个方向编写。
Example:
例:
Some content
Output
输出量
margin: 1px; margin: 1px 1px; margin: 1px 1px 1px; margin: 1px 1px 1px 1px;
To provide margins for left, right, top and bottom to an object, we can use margin-left, margin-right, margin-top and margin-bottom properties respectively.
要为对象的左侧,右侧,顶部和底部提供边距,我们可以分别使用margin-left , margin-right , margin-top和margin-bottom属性。
Example:
例:
This is line One.
This is line Two.
This is line Three.
This is line Four.
Output
输出量
翻译自:
css中图片左右边距
转载地址:http://ditzd.baihongyu.com/