CSS样式表命名规则
样式选择符命名
选择符以类型分,同类放一起,类的定义顺序以HTML中实际的顺序为参考,以方便查找为主, 使用类似下面的规则:
[模块前缀 | 类型 | 作用]_[名称]_[状态 | 位置]
约定模块、类型、状态、位置等的所使用的单词或其缩写,保持上面的顺序,尽量保持在两到三个单词说清用途。
通用名词缩写
设置
set
文本
txt
成功
suc
颜色
c
提示
hint
背景
bg
操作
op
边框
bor
密码
pw
居中
center
菜单
menu
图标
icon
按钮
btn
弹出
pop
例:
文本输入框 .input_tx
密码输入框 .input_pw
登录密码输入框 .input_pw_login
日志设置成功提示 .hint_suc_blogset
相册弹出的设置层 .pop_set_photo
公共提示 .hint_bg
文本颜色 .c_tx
段落文本颜色 .c_tx_p
样式属性书写顺序
mozilla.org Base Styles
/Suggested order:
//显示属性
//自身属性
//文本属性
* display
* width
* color
* list-style
* height
* font
* position
* margin
* text-decoration
* float
* padding
* text-align
* clear
* border
* vertical-align
* background
* white-space
* other text
* content
从本质到表象,顺时针,从外到内,从上到下
/* 1、本质:清理外部clear,显不显示display,是否可见visibility,什么状态overflow,什么位置position,在哪float…. */
clear; display; visibility; overflow; position; float; list-style; ….
/* 2、自身:多宽width,多高height,行高line-height,对外margin,对内padding…. */
width; height; line-height; margin; padding; ….
/* 3、修饰:字体font,颜色color,文本text,边框border,背景background…. */
font; color; text; border; background; ….
相关文档:
1.css 字体简写规则
当使用css定义字体时你可能会这样做:
font-size: 1em;
line-height: 1.5em;
font-weight: bold;
font-style: italic;
font-variant: small-caps;
font-family: verdana,serif;
事实上你可以简写这些属性:
font: 1em/1.5em bold italic small-caps ver ......
css默认的布局是将元素一个一个地往下排列下来,如果不采取浮动,将导致页面非常长。
下面我们通过做一个常见的网站布局,来说明浮动是怎么一回事。
希望的效果是:
步骤一、先把代码写一下,
例:
html内容:
<body >
<div id="head">
head
</div>
<div id="content">
c ......
/*控制图片的大小*/
.contentimg{
max-width:600px;
/*max-height:100px;*/
}
*html.contentimg{
width:expression(this.width>50&&this.width>this.height?60:auto);
/*height:expresion(this.height>50?50:auto);
*/
}
调用
$("#"+id.substring(0,id.length-5)+"arCon"). ......
1.CSS字体属性简写规则一般用CSS设定字体属性是这样做的:
font-weight:bold;
font-style:italic;
font-varient:small-caps;
font-size:1em;
line-height:1.5em;
font-family:verdana,sans-serif;
但也可以把它们全部写到一行上去:
font: bold italic small-caps 1em/1.5em verdana,sans ......
首先感谢“丸子
”提供的这个
IE8的css hack;
关注过IE8的css hack的人相信大家都在使用这个hack,就是“\9”的css hack:
.test{
color:#000000; /* FF,OP支持 */
color:#0000FF\9;&n ......