网络学院 w3pop社区 网络资源 IT新闻

w3pop.com :: 网络学院 :: CSS :: CSS margin属性

会员登陆

帐号

密码

回答

记住密码

忘记密码? 注册

CSS margin属性


作者:w3pop.com 翻译/整理:w3pop.com 发布:2007-04-28 浏览:2867 :: ::

The margin property is a shorthand property for setting all of the properties for the four margins in one declaration.
margin 速记法属性可在一句声明中设置所有四个边际的属性

Note: Negative values are allowed.
注意:可以使用负数

Inherited: No
继承性:无

举例

h1 {margin: 10px}
all four margins will be 10px
所有四个方向的边际都是10像素

h1 {margin: 10px 2%}
top and bottom margin will be 10px, left and right margin will be 2% of the total width of the document.
上下的边际为10像素,左右边际为文档总宽度的2%

h1 {margin: 10px 2% -10px}
top margin will be 10px, left and right margin will be 2% of the total width of the document, bottom margin will be -10px
上边际为10像素,左右边际为文档总宽度的2%,下边际为-10px

h1 {margin: 10px 2% -10px auto}
top margin will be 10px, right margin will be 2% of the total width of the document, bottom margin  will be -10px, left margin will be set by the browser
上边际为10px,右边际为文档总宽度的2%,下边际为-10px,左边际则由浏览器自动设定。

可用值

描述
margin-top
margin-right
margin-bottom
margin-left
Sets the properties for the margins. The values comes in % (defines a margin in % of the total height/width of the document), length (defines a fixed margin), and auto (the browser sets a margin).
设置边际属性,值可以是百分比(根据文档的宽/高来定义),长度(定义固定的边际)以及自动(由浏览器自行设定)

评论 (0) All