易截截图软件、单文件、免安装、纯绿色、仅160KB

Web开发 第二部分 CSS基础(二) CSS书写规范

1、三种不同的样式表
样式表根据其书写位置不同,共分为三种:
内联样式表(inline):该样式表写在标签的style属性里,负责设置当前标签的样式;
内部样式表(inner):该样式表一般写在head标签的style标签里,通过选择器来指定某个样式所影响的标签;
外部样式表(external):该样式表一般写在独立的*.css文件里,通过选择器来指定某个样式所影响的标签,在head标签通过link标签引入外部样式文件;
看一个例子,共两个文件,在同一个目录中:
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="content-type" content="text/html; charset=gb2312" />

<!-- 这里引入了一个外部样式表 -->
<link type="text/css" rel="stylesheet" href="style.css" mce_href="style.css" />

<!-- 这是一个内部样式表 -->
<mce:style type="text/css" ><!--

b { /* 这是一个标签选择器 */
background-color:#B0D1E6;
color:blue;
text-indent:2em;
text-align:left;
}

.title { /* 这是一个类选择器 */
color:#209DA4;
text-decoration:underline;
text-align:left;
}

#id1 { /* 这是一个ID选择器 */
background-color:#5E5E5E;
color:#FFFFFF;
font-weight:bold;
height:100px;
width: 300px;
border: 2px dotted #C7784E;
word-break:break-all;
overflow-y:auto;
overflow-x:hidden;
text-indent:2em;
margin:0 auto;
}

--></mce:style><mce:style type="text/css" mce_bogus="1"><!--

b { /* 这是一个标签选择器 */
background-color:#B0D1E6;
color:blue;
text-indent:2em;
text-align:left;
}

.title { /* 这是一个类选择器 */
color:#209DA4;
text-decoration:underline;
text-align:left;
}

#id1 { /* 这是一个ID选择器 */
background-color:#5E5E5E;
color:#FFFFFF;
font-weight:bold;
height:100px;
width: 300px;
border: 2px dotted #C7784E;
word-break:break-all;
overfl


相关文档:

css与js属性对照表


盒子标签和属性对照
CSS语法(不区分大小写)
JavaScript语法(区分大小写)
border
border
border-bottom
borderBottom
border-bottom-color
borderBottomColor
border-bottom-style
borderBottomStyle
border-bottom-width
borderBottomWidth
border-color
borderColor
border-left
borderLeft
border ......

CSS RESET

/* reset */
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,p,blockquote,th,td{margin:0;padding:0;font-family:'宋体';}
div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,a,span {overflow:hidden;}
table{border-collapse:collapse;border-spacing:0; font-size:12px;}
td { line-height:18px ......

CSS强制不换行(white space:nowrap)IE使用问题

什么情况下会出现换行:
当元素设置了固定高度,并且文本长度大于标签元素的宽度时,文本会自动换行。
css强制换行使用样式:white-space:nowrap;该样式从效果上是没有浏览器差异,使用该样式后所有文字在ie和firefox下都在一行内显示。但是在IE下使用该属性值后标签元素宽度会被撑大,从而可能导致原来页面布局被破坏。 ......

FireFox与IE中CSS兼容技集锦

1 针对firefox ie6 ie7的css样式
现在大部分都是用!important来hack,对于ie6和firefox测试可以正常显示,
但是ie7对!important可以正确解释,会导致页面没按要求显示!找到一个针
对IE7不错的hack方式就是使用“*+html”,现在用IE7浏览一下,应该没有问题了。
现在写一个CSS可以这样:
#1 { color: #33 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号