繁体中文
设为首页
加入收藏
当前位置:学院首页 >> 网页设计 >> Css >> css新手上路(6)

css新手上路(6)
2007-01-31 11:25:10  作者:bluelove  来源:互连网  浏览次数:0  网友评论0  文字大小:【】【】【】 评分等级:0

这一节我们讨论如何用 CSS 来控制四周的空格以及边框
的设定

元素周边的空格 margin
性质 margin 可被用来决定周边的空格, 假如我们想让整
个网页在左边有 5em 但让标题没有任何空格

  BODY {margin: 5em}
  H3 {margin: -5em}
H3 的负值 -5em 抵销了 BODY 5em 的空格。

另外我们还可以分别用 margin-left, margin-right, margin-top,
和 margin-bottom 来设定 左,右,上,下的空格

元素内部周边的空格 padding
初看起来这个性质跟 margin 好象一样。 其实它们之间有
很大的区别。margin 的空格是相对于其他的元素所空的,
而 padding 是在元素的周边和内部的内容所空的空格。在
下面的例子,我们用有背景颜色的 TABLE 来让你注意这
个性质

  TABLE.pad {padding: 5mm; background-color: #CCEFCC}
Petersen was arrested in a modest apartment building in Studio City, Calif., which he had been sharing with three other people. The Marshals entered the apartment using a key provided by the building's manager. When they entered, the Marshals said, they
found Petersen alone -- sitting on his bed and using his laptop computer. 

我们同样可以用 padding-left, padding-right, padding-top, 和
padding-bottom 来分别控制左,右,上,下的元素内部
的周边空格。

元素边框的宽度
我们可以用 border-width 性质来调节边框的宽度。 比如

  P.width5 {border-width: 1px}
这个 P 元素的边框宽度是 1 px

你可以用 border-left-width, border-right-width, border-top-width,
和 border-bottom-width 来分别决定左,右,上,下边的宽度

元素边框的颜色
我们可以用 border-color 性质来调节边框的颜色。 比如

  P.colorred {border-color: red}
这个 P 元素的边框的颜色是红色的

元素边框的形态
我们可以用 border-style 性质来调节边框的形态。 比如

  P.inset {border-style: inset, border-width: 5px}
这个 P 元素的边框的形态是 inset

这个 P 元素的边框的形态是 outset

这个 P 元素的边框的形态是 double

这个 P 元素的边框的形态是 groove

这个 P 元素的边框的形态是 ridge


本文引用地址:http://edu.yinaite.com/601.html

责任编辑:cxm

发表评论】 【加入收藏】 【告诉好友】 【打印本页】 【关闭窗口】 【返回顶部
相关评论 0条评论  发表/查看更多评论 
发表评论  【返回顶部】【关闭窗口】 
评分: 1 2 3 4 5

    
  • 请遵守《互联网电子公告服务管理规定》及中华人民共和国其他各项有关法律法规。
  • 严禁发表危害国家安全、损害国家利益、破坏民族团结、破坏国家宗教政策、破坏社会稳定、侮辱、诽谤、教唆、淫秽等内容的评论 。
  • 用户需对自己在使用本站服务过程中的行为承担法律责任(直接或间接导致的)。
  • 本站管理员有权保留或删除评论内容。