当前位置: 首页 > 网络学院 > 网页制作基础教程 > CSS > CSS margin属性

CSS
CSS2 Aural
CSS 单位
CSS 颜色
CSS 颜色值
CSS 颜色名称
CSS 编码与组织技巧
CSS 模块化设计思路
CSS完美兼容IE6/IE7/FF的通用方法
CSS @ Ten: 下一个重要的东西

CSS margin属性


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 363 ::
收藏到网摘: n/a

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

登陆 | 还没注册?