CSS |左边距属性
CSS 中的左边距属性用于设置所需元素左边距的宽度。允许该属性的负值。
- 当希望边距远离其邻居时,使用正值。
- 当需要将边距放得更近时,使用负值。
语法:
margin-left: length|auto|initial|inherit;
默认值:其默认值为 0。
属性值:
-
length : Sets a fixed value defined in px, cm, pt. Negative values as mentioned earlier are allowed. 0 px is the default value.
```html margin-left: 15px;
```
例 1 :
```html
CSS | margin-left PropertyThis paragraph has 15px margin .
```例 2 :
```html
CSS | margin-left PropertyThis paragraph has 20% margin .
``` -
auto :It is used when it is desired that the browser determines the width of the left margin.
```html margin-left: auto;
```
例:
```html
CSS | margin-left PropertyThis paragraph has auto margin .
``` -
initial :It is used to set the value of the margin-left property to its default value.
```html margin-left: initial;
```
例:
```html
CSS | margin-left PropertyThis paragraph has initial margin .
``` -
inherit :It is used when it is desired that the element inherit the margin-left property of its parent as its own.
```html margin-left: inherit;
```
例 1 :
```html
CSS | margin-left PropertyThis paragraph has auto margin .
例 2 :
```html
CSS | margin-left PropertyThis paragraph has auto margin .
This paragraph has 10px margin.
This paragraph has 5% margin.
This text has an margin of 15px.
This text has a margin of default typeset by initial
```
支持的浏览器:左边距属性支持的浏览器如下:
- 谷歌 Chrome 1.0
- Internet Explorer 6.0
- 歌剧 3.5
- Firefox1.0
- Safari 1.0
版权属于:月萌API www.moonapi.com,转载请注明出处