css中的选择器
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title > css selector</title>
<style type="text/css">
/* 元素选择器 */
h2 {color:green;}
/* 分组选择器 */
div,p {
background-color:#dcdcdc;
}
/* 类选择器 */
.redfont {
color:red;
}
/* text-transform样式使用结合类选择器 */
h1 {text-transform: uppercase}
p.uppercase {text-transform: uppercase}
p.lowercase {text-transform: lowercase}
p.capitalize {text-transform: capitalize}
/* 属性选择器 */
input[value] {
color: #029AE5;
font-weight: bolder;
font-family: "微软雅黑";
font-size: 26px;
}
/* ID选择器 */
#id02 {
font-family: "Times New Roman", Times, serif;
font-size: 36px;
}
/* 后代选择器 */
h3 em {
font-family: "黑体";
font-size: 24px;
line-height: 1.5em;
color: #FC531F;
}
/* 子元素选择器 */
table.querytable tr > td {
background-color: green;
}
/* 相邻兄弟选择器 */
li + li {
font-weight:bold;
}
/* 伪类 */
a:link {color: #FF0000} /* 未访问的链接 */
a:visited {color: #00FF00} /* 已访问的链接 */
a:hover {color: #FF00FF} /* 鼠标移动到链接上 */
a:active {color: #0000FF} /* 选定的链接 */
/* 伪类举例2 */
/* p:first-child {font-weight: bold;}
li:first-child {text-transform:uppercase;}
p:first-child {font-weight: bold;}
li:first-child {text-transform:uppercase;} */
/* 伪元素 */
/*
:before
:after
:first-line
:first-letter
*/
p.article:first-letter {
color: #ff0000;
font-size:xx-large
}
</style>
</head>
<body>
<h2>1.元素选择器</h2>
<div style = "width:100%;">
hello
</div>
<h2>2.类选择器</h2>
<div style = "width:100%;">
<p class="redfont">hello</p>
<!-- text-transform使用 -->
<h1>text-transform</h1>
<p class="uppercase">this uppercase</p>
<p class="lowercase">this lowercase</p>
<p class="capitalize">this capitalize</p>
</div>
<h2>3.属性选择器</h2>
<div style = "width:100%;">
<input id="id01" type="text" value="test" />
</div>
<h2>4.ID选择器</h2>
<div style = "width:100%;">
<p id="id02">hello world</p>
</div>
<h2>5.后代选择器</h2>
<div style = "width:100%;">
<h3>
<em>后代选择器</em>
</h3>
</div>
<h2>6.子元素选择器</h2>
<div style = "width:100%;">
<table class="querytable">
<tr>
<td>张三</td>
<td>张三</td>
<td>张三</td>
</tr>
<tr>
<td>李四</td>
<td>李四</td>
<td>李四</td>
</tr>
<tr>
<td>王五</td>
<td>王五</td>
<td>王五</td>
</tr>
</table>
</div>
<h2>7.相邻兄弟选择器</h2>
<div style = "width:100%;">
<ul>
<li>list11</li>
<li>list12</li>
<li>list13</li>
</ul>
<ol>
<li>list21</li>
<li>list22</li>
<li>list23</li>
</ol>
</div>
<h2>7.伪类</h2>
<div style = "width:100%;">
<p><b><a href="../index.html" target="_blank">这是一个链接。</a></b></p>
<p><b>注释:</b>在 CSS 定义中,a:hover 必须位于 a:link 和 a:visited 之后,这样才能生效!</p>
<p><b>注释:</b>在 CSS 定义中,a:active 必须位于 a:hover 之后,这样才能生效!</p>
</div>
<h2>7.伪元素</h2>
<div style = "width:100%;">
<p class="article">
You can use the :first-letter pseudo-element to add a special effect to the first letter of a text!
</p>
</div>
<h2>8.分组选择器</h2>
<div style = "width:100%;">
hello world
</div>
</body>
</html>