CSS常用操作
注释用/**/。
不要在属性值与单位之间留有空格。假如你使用 “margin-left:20 px” 而不是 “margin-left:20px” (20和px之间有空格),它仅在 IE 6 中有效,但是在 Mozilla/Firefox 或 Netscape 中却无法正常工作。
外部样式表引用方式:<link rel="stylesheet" type="text/css" href="mystyle.css" mce_href="mystyle.css" />
内部样式表:
<head>
<mce:style type="text/css"><!--
hr {color: sienna;}
p {margin-left: 20px;}
body {background-image: url("images/back40.gif");}
h1,h2,h2,h3,h5,h6 {color: green;}
--></mce:style><style type="text/css" mce_bogus="1"> hr {color: sienna;}
p {margin-left: 20px;}
body {background-image: url("images/back40.gif");}
h1,h2,h2,h3,h5,h6 {color: green;}</style>
</head>
内联样式:<p style="color: sienna; margin-left: 20px" mce_style="color: sienna; margin-left: 20px">This is a paragraph</p>
---------------------------------------------
样式可以被继承:
例如,外部样式表拥有针对 h3 选择器的三个属性:
h3 {
color: red;
text-align: left;
font-size: 8pt;
}
而内部样式表拥有针对 h3 选择器的两个属性:
h3 {
text-align: right;
font-size: 20pt;
}
假如拥有内部样式表的这个页面同时与外部样式表链接,那么 h3 得到的样式是:
color: red;
text-align: right;
font-size: 20pt;
---------------------------------------------
提示:如果值为若干单词,则要给值加引号:p {font-family: "sans serif";}。只有当一个字体名中有一个或多个空格(比如 New York),或者如果字体名包括 # 或 $ 之类的符号,才需要在 font-family 声明中加引号。
派生选择器:
strong {
color: red;
}
h2 {
color: red;
}
h2 strong {
color: blue;
}
<h2>The strongly emphasized word in this subhead is<strong>blue</strong>.</h2>
---------------------------------------------
id 选择器:
id 选择器可以为标有特定 id 的 HTML 元素指定特定的样式。id 选择器以 "#" 来定义。
#red {color:red;}
#green {color:green;}
下面的 HTML 代码中,id 属
相关文档:
<div style="FILTER:alpha(opacity=30 finishopacity=0 style=1) progid:DXImageTransform.Microsoft.gradient(startcolorstr=red,endcolorstr=blue,gradientType=1); VERTICAL-ALIGN: middle; BORDER-LEFT: #f3f3f3 1px solid; WIDTH: 300px; PADDIN ......
/*不管是什么方法,书写的顺序都是firefox的写在前面,IE7的写在中间,IE6的写在后面。*/
.JS_CenterAD_marquee_Right
{
margin-left:17px !important; /firefox*/
*margin-left:17px !important; / ......
在许多网站上我们可以看到很个性的鼠标指针(cursor),在网页设计中用CSS可以方便的实现这样个性鼠标指针的效果,该CSS属性就是"cursor"属性。
首先我们介绍一下系统自带的15个鼠标效果:
一般而言,鼠标以斜向上的箭头显示,移到文本上时变为有头的竖线,移到超级链接上变为手型。但用css可控制鼠标的显示效果,如可使鼠标 ......
CSS对浏览器的兼容性有时让人很头疼,或许当你了解当中的技巧跟原理,就会觉得也不是难事,从网上收集了IE7,6与Fireofx的兼容性处理方法并整理了一下.对于web2.0的过度,请尽量用xhtml格式写代码,而且DOCTYPE 影响 CSS 处理,作为W3C的标准,一定要加 DOCTYPE声名.
CSS技巧
1.div的垂直居中问题
vertical-align:middl ......
基于IE与css的表格行头与多层列头锁定方法
(左边图锁定了行头与列头,右边图仅锁定列头)
有许多的锁定或固定html表格表头的方法和技术,本文介绍的是一个基于IE和css的简易实现方法,基本思路为:使用div行级元素确定一个包含表格的区域,在区域滚动移动时定位非固定单元格的位置(top/left) ......