menu

开发进行时...

crazy coder

Avatar

begin with css

1字体选择和默认值
body{font-family:"Lucida Grande",Verdana,Lucida,Arial,Helvetica,sans-serif;}
2群选择器
p,td,ul,ol,li,dl,dt,dd{font-size:small;}
3继承

4内容(派生)选择器
li strong{font-style:italic;
font-weight:normal;}
eg. <p><strong>I am bold and not italic because I don't appear in a list item. Then rule has no affect on me.</strong></p>
<ol>
<li><strong>I am italic and of Roman (normal) weight because I occr within a list item.</strong></li>
<li>I am ordinary text in this list.</li>
</ol>
5id选择器和内容id选择器
id选择器常用在内容选择器里:
#sidebar p{font-style:italic;text-align:right;margin-top:0.5em;}
只用于id为sidebar的元素里的段落,该元素极可能是一个div或表格单元,虽然也可能是一个表格或是一引些其他的块级元素,甚至可能是一个内联元素,如<em>或<span>。这样的用法有些古怪,也是非法的--不能把<p>套入<span>中,但不考虑那些使用过的元素,它就是该页中惟一使用id为sidebar的元素。
可单独使用
#sidebar{border:1px dotted #00;padding:10px}点状边界
6类别选择器
把类别属性进行分别定义在样式表中的效果很好,在CSS里用一个点表示类别选择器:
.fancy{color:#60;background:#666;}
如id一样,类别选择器也可用做内容选择器:
.fancy td{color:#f60;background:#666;}
也可以根据其类别挑选元素:
td.fancy{color:#f60;background:#666;}
定义为:用td元素来选择类别名称fancy

评论已关闭