网站运营网:WWW.WEBYYW.COM PR值查询 | 收录查询 | Alexa查询 | 友情链接检查

热门搜索: seo  网赚  网站运营
网站logo,点击返回首页
网站banner

icon 当前位置:主页 > 网站制作 > 查看页面

CSS简写用法说明

tags:CSS   来源:网络   时间:2008-08-14  
简单的说,css简写就是在等效的前提下,把多句css代码简化成一句。在我看来,简写css的好处有三:一是写起来方便(就像键盘快捷键);二是简化代码;三是帮助你熟悉和深刻理解css。

闲话少说,书归正传。能够简写的css属性主要有以下几个:

font 简写:

font:italic small-caps bold 12px/1.5em arial,verdana;等效于:

font-style:italic;
font-variant:small-caps;
font-weight:bold;
font-size:12px;
line-height:1.5em;
font-family:arial,verdana;顺序:font-style | font-variant | font-weight | font-size | line-height | font-family
(注:简写时,font-size和line-height只能通过斜杠/组成一个值,不能分开写。)

background 简写:

background:#fff url(bg.gif) no-repeat fixed left top;等效于:

background-color:#fff;
background-image:url(bg.gif);
background-repeat:no-repeat;
background-attachment:fixed;
background-position:left top;顺序:background-color | background-image | background-repeat | background-attachment | background-position

margin & padding 简写:

margin:1px 0 2em -20px;等效于:

margin-top:1px;
margin-right:0;
margin-bottom:2em;
margin-left:-20px;顺序:margin-top | margin-right | margin-bottom | margin-left

padding的简写和margin完全一样。

border 简写:

border:1px solid #000;等效于:

border-width:1px;
border-style:solid;
border-color:#000;顺序:border-width | border-style | border-color

这三句也是简写,等于是把四边的样式合而为一了。(关于四边的问题,下文有详细说明)

border-top / border-right / border-bottom / border-left 简写:

border-top:1px solid #000;等效于:

border-top-width:1px;
border-top-style:solid;
border-top-color:#000;(和border一样)

list-style 简写:

list-style:square outside url(bullet.gif);等效于:

list-style-type:square;
list-style-positionutside;
list-style-image:url(bullet.gif);顺序:list-style-type | list-style-position | list-style-image
查看所有评论最新评论共有 0 位网友发表了评论
发表评论

评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。

网友

网站运营网 | 高级搜索 | 网站TAG | 加入链接 | 网站地图 | RSS订阅 | 联系我们
Power by DedeCms 冀ICP备08000797号