批改状态:合格
老师批语:手写代码未提交!请及时提交!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>0321作业:基本选择器和属性选择器</title>
<style type="text/css">
ul {
padding: 0;
margin: 0;
width: 500px;
border: 1px dashed #666;
padding: 10px 5px;
}
ul:after {
content: '';
display: block;
clear: both;
}
li {
list-style: none;
float: left;
width: 40px;
line-height: 40px;
text-align: center;
border-radius: 10%;
background-color: skyblue;
margin-right:5px;
}
/*根据属性名来选择元素,选中所有带id属性的元素*/
*[id] {
background-color: red;
}
/*根据属性名和值来选元素*/
li[class="green"] {
background-color: lightgreen;
}
li[class ~="red"] {
background-color: brown;
}
/*选择以ph开头的类样式的元素*/
li[class ^="ph"] {
background-color: coral;
}
li[class $="s"] {
background-color: lime;
}
/*选择属性中包括字母e的元素*/
li[class *="e"] {
background-color: yellowgreen;
}
</style>
</head>
<body>
<ul>
<li id="item1">A</li>
<li class="green">B</li>
<li class="green">C</li>
<li class="red">D</li>
<li>E</li>
<li >F</li>
<li id="item2">G</li>
<li class="php">H</li>
<li class="php css">I</li>
<li>J</li>
</ul>
</body>
</html>点击 "运行实例" 按钮查看在线实例
手抄代码:




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