css基础
2014-07-16 10:04
176 查看
1、CSS 指层叠样式表 (Cascading Style Sheets)
2、设置标题h1~h6为绿色。
color: green;
}[/code]
3、列表中的strong元素变为斜体。
font-style: italic;
font-weight: normal;
}[/code]
4、id选择器。(id为red内的p元素和h2元素都得到了特殊处理)
<p
5、类选择器(类名为center的表格单元文本都为居中对齐)
6、属性选择器
2、设置标题h1~h6为绿色。
h1,h2,h3,h4,h5,h6{
color: green;
}[/code]
3、列表中的strong元素变为斜体。
li strong{
font-style: italic;
font-weight: normal;
}[/code]
4、id选择器。(id为red内的p元素和h2元素都得到了特殊处理)
#redp {color:red;}[/code]
#red h2{font-size: 1em;font-weight: normal;}[/code]
#green{color:green;}
<p [code]id="red">这个段落是红色。</p>
<p
id="green">这个段落是绿色。</p>[/code]
5、类选择器(类名为center的表格单元文本都为居中对齐)
.centertd {text-align: center}[/code]
6、属性选择器
[title]{border:5px solid blue;}//只要带有title属性的元素都有蓝色的边框[/code]
[title=W3School]{border:5px solid blue;}//带有title属性,且值为W3School的元素都有蓝色的边框[/code]
[title~=hello]{ color:red; }//title属性包含值是hello的元素字体都为红色[/code]
[lang|=en] { color:red; }//带有包含指定值en的 lang 属性的所有元素设置样式(字体为红色)
相关文章推荐