批改状态:未批改
老师批语:
<!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: 50%;
background-color: skyblue;
margin-right:5px;
}
/*id选择器*/
#item1 {
background-color: red;
}
/*类选择器*/
.green {
background-color: lightgreen;
}
/*父子选择器*/
ul li {
color: white;
}
/*通配选择器*/
ul * {
/*border: 1px solid black;*/
}
/*子元素选择器*/
ul > li {
background-color: blue;
}
/*相邻兄弟选择器*/
#item2 + li {
/*background-color: black;*/
}
#item2 ~ li {
background-color: black;
}
/*-------------------------------*/
</style>
</head>
<body>
<ul>
<li id="item1">A</li>
<li class="green">B</li>
<li class="green">C</li>
<li>D</li>
<li>E</li>
<li id="item2">F</li>
<li>G</li>
<li>H</li>
<li>I</li>
<li>J</li>
</ul>
</body>
</html>点击 "运行实例" 按钮查看在线实例
手抄代码:




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