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强制换行使用样式:white-space:nowrap;该样式从效果上是没有浏览器差异,使用该样式后所有文字在ie和firefox下都在一行内显示。但是在IE下使用该属性值后标签元素宽度会被撑大,从而可能导致原来页面布局被破坏。
......
CSS分栏布局的方法:绝对定位和浮动
出处:网页教学网
作者:佚名
日期:2009-03-09
在CSS中,实现分栏布局有两种方法。第一种方法是使用四种CSS定位选项(absolute
、static、relative和fixed)中的绝对定位(absolute
positioning),它可以将文档中的某个元素从其原本位置上移除,并重新定位 ......
CSS,层叠样式表的作用是什么?我们先通过一个例子来体会一下:
看代码:
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv=" ......
来自:http://www.51xflash.com/website/html/200905/01-8904.html
CSS代码: (插入到CSS文件的最顶端)
html { filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); }
或者:
*{filter: Gray;}
HTML代码: (插入到页面HTML源码的<HEAD>和</HEAD>之间)
<style>html{filter:progid:DXIm ......