css基础

来源:互联网 发布:linux磁盘io使用过高 编辑:程序博客网 时间:2024/06/18 13:24

1、CSS 指层叠样式表 (Cascading Style Sheets)

2、设置标题h1~h6为绿色。

h1,h2,h3,h4,h5,h6 {  color: green;  }
3、列表中的strong元素变为斜体。

li strong {    font-style: italic;    font-weight: normal;  }
4、id选择器。(id为red内的p元素和h2元素都得到了特殊处理)

#red p {color:red;}
#red h2 {font-size: 1em;font-weight: normal;}

#green {color:green;}
<p id="red">这个段落是红色。</p><p id="green">这个段落是绿色。</p>

5、类选择器(类名为center的表格单元文本都为居中对齐)

.center td {text-align: center}
6、属性选择器

[title]{border:5px solid blue;}//只要带有title属性的元素都有蓝色的边框
[title=W3School]{border:5px solid blue;}//带有title属性,且值为W3School的元素都有蓝色的边框
[title~=hello] { color:red; }//title属性包含值是hello的元素字体都为红色
[lang|=en] { color:red; }//带有包含指定值en的 lang 属性的所有元素设置样式(字体为红色)








0 0
原创粉丝点击