步入xhtml标准时代,CSS已经是不可或缺的东西了。有效的缩小CSS文件的体积可以让你的网站速度得到绝对的速度的提升。

CSS缩写性质的列表以及它们所表示的常规性质。

Background(背景):背景附件、背景颜色、背景图像、背景位置、背景重复
Border(边框):边框颜色、边框风格、边框宽度
border-bottom(底部边框):底部边框颜色、底部边框样式、底部边框宽度
border-left(左侧边框):左侧边框颜色、左侧边框样式、左侧边框宽度
border-right(右侧边框):右侧边框颜色、右侧边框样式、右侧边框宽度
border-top(顶部边框):顶部边框颜色、顶部边框样式、顶部边框宽度
cue(声音提示):前提示、后提示
font(字体):字体、字号、字体样式、字体粗细、字体变体、线高度、字体大小调整、字体拉伸
list-style(列表样式):列表样式图像、列表样式位置、列表样式类型
margin(空白):顶部空白、右侧空白、底部空白、左侧空白
outline(大纲):大纲颜色、大纲样式、大纲宽度
padding(间隙):顶部间隙、右侧间隙、底部间隙、左侧间隙
pause(暂停):后暂停、前暂停
减少空白

例如:

.sample1 {
margin-top: 15px;
margin-right: 20px;
margin-bottom: 12px;
margin-left: 24px;
padding-top: 5px;
padding-right: 10px;
padding-bottom: 4px;
padding-left: 8px;
border-top-width: thin;
border-top-style: solid;
border-top-color: #000000;
}

将它用一些缩写性质来替代就能够把代码减少为下面这样,两者的实际效果是完全一样的:

.sample1 {
margin: 15px 20px 12px 24px;
padding: 5px 10px 4px 8px;
border-top: thin solid #000000;
}
看看。代码是不是少了不少呢?一般可以压缩25%~50%的!

posted on 2004-12-26 21:01  维生素C.NET  阅读(1164)  评论(3)    收藏  举报