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

CSS
CSS 介绍
CSS 语法
使用 CSS
CSS 背景
CSS 文字
CSS 字体
CSS 边框
CSS 边距
CSS 填充
CSS 列表
CSS 尺寸
CSS 类别
CSS 定位
CSS 伪类
CSS 伪元素
CSS2 Media类型
CSS 摘要
CSS 实例
CSS2 参考资料
CSS2 打印

CSS margin属性


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 362 ::
收藏到网摘: 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

登陆 | 还没注册?