批改状态:未批改
老师批语:
基本选择器:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>基本选择器</title>
<style type="text/css">
h1{
size: 44px;
color:red;
}
#t1{
size: 22px;
color: yellow;background-color: green
}
.green{
size: 58;background-color: yellow
}
ol li{
size: 35;color:DarkMagenta;
}
tr * {
background-color: red
}
ul > li{
color:#8B0000;
}
</style>
</head>
<body>
<h1 style="color: blue">元素选择器</h1>
<ul type="none">
<li id="t1">ID选择器/#加ID值</li>
<li class="green">类选择器1/.+class值</li>
<li class="red">3</li>
<li class="green">类选择器2</li>
<li>5</li>
<li id="t2">6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
</ul>
<ol>
<li>父子选择器</li>
<li>父子选择器</li>
<li>父子选择器</li>
<li>父子选择器</li>
</ol>
<table border="1">
<tr>
<th>通配选择器</th>
<th>通配选择器</th>
<th>通配选择器</th>
</tr>
</table>
<dl>
<dt>子元素选择器</dt>
<dd>子元素选择器</dd>
</dl>
</body>
</html>点击 "运行实例" 按钮查看在线实例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>基本选择器2</title>
<style type="text/css">
ol > li{
font-size: 67px;color: red;
}
#t2 + li{
background-color: blue;color: red
}
#t3 ~ li{
color: skyblue
}
</style>
</head>
<body>
<h1 style="color: blue">元素选择器</h1>
<ul type="none">
<li id="t1">ID选择器/#加ID值</li>
<li class="green">类选择器1/.+class值</li>
<li class="red">3</li>
<li class="green">类选择器2</li>
<li>5</li>
<li id="t2">6</li>
<li>相邻兄弟选择器</li>
<li id="t3">8</li>
<li>全部兄弟选择器</li>
<li>全部兄弟选择器</li>
<li>全部兄弟选择器</li>
</ul>
<ol>
<li>子元素选择器</li>
<li>子元素选择器</li>
<li>子元素选择器</li>
<li>子元素选择器</li>
</ol>
<table border="1">
<tr>
<th>通配选择器</th>
<th>通配选择器</th>
<th>通配选择器</th>
</tr>
</table>
</body>
</html>点击 "运行实例" 按钮查看在线实例
属性选择器
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>属性选择器</title>
<style type="text/css">
* [id] {
size: 44px;color: red;
}
li[class="green"]{
size:55px;background: red;
}
li[class~="red"]{
color: blue
}
li[class ^= "ph"] {
background-color: coral;
}
li[class $= "s"]{
color:skyblue
}
li[class *= "a"]{
background-color: lime;
}
</style>
</head>
<body>
<ul type="none">
<li id="item1">根据属性名来选择“id属性”</li>
<li class="green">根据属性名与值来选择</li>
<li class="green red">选择class属性值中包括指定单词的元素RED</li>
<li class="red">选择class属性值中包括指定单词的元素red</li>
<li class="abc">选择属性值中包括指定字母'a'的类样式元素</li>
<li id="item2">根据属性名来选择“id属性”</li>
<li class="php">选择以'ph'字母开头的class类样式元素</li>
<li class="php css">选择以'ph'字母开头的class类样式元素+选择以's'结尾的类样式元素</li>
<li>9</li>
<li>10</li>
</ul>
</body>
</html>点击 "运行实例" 按钮查看在线实例
手抄基础选择器


Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号