
批改状态:合格
老师批语:总得来说写的不错!
div{
background-color:red;
}
.lei{
background-color:red;
}
.lei.lei2{
background-color:red;
}
#idming{
background-color:red;
}
.lei div{
background-color:#999;
}
body>div{
background-color:pink;
}
同级相邻选择器
.item.center + .item{
background-color:pink;
}
同级所有选择器(.item.center后面的所有的item类元素)
.item.center ~ .item{
background-color:pink;
}
.hello>:first-child{
background-color:wheat;
}
/*类选择器 .hello下面的第一个子元素*/
.item>:last-child{
background-color:wheat;
}
.item>:nth-child(3){
background-color:wheat;
/*数字从1开始*/
}
.item>:nth-child(2n){
background-color:red;
/*偶数div变成了红色*/
}
.item>:nth-child(2n-1){
background-color:red;
/*奇数div变成了红色*/
}
.item>:nth-child(odd){
background-color:red;
/*奇数div变成了红色*/
}
:nth-child (-n+3)只取前3个
:nth-last-child (-n+3)只取最后3个
:nth-last-child (2)取倒数第2个
在分组中根据索引进行选择
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
#login-form {
display: none;
}
#login-form:target {
display: block;
}
</style>
<title></title>
</head>
<body>
<button onclick="location='#login-form'">
点击登陆
</button>
<form action="" method="post" id="login-form">
<label for="email">邮箱:</label>
<input type="email" name="email" id="email" />
<br />
<label for="password">密码:</label>
<input type="password" name="password" id="password" />
<button type="button">登陆</button>
</form>
</body>
</html>
点击后
<style type="text/css">
#login-form {
display: none;
}
#login-form:target {
display: block;
}
/* 当鼠标获得焦点的时候 */
input:focus {
background-color: chartreuse;
}
</style>
<title></title>
</head>
<body>
<button onclick="location='#login-form'">
点击登陆
</button>
<form action="" method="post" id="login-form">
<label for="email">邮箱:</label>
<input type="email" name="email" id="email" />
<br />
<label for="password">密码:</label>
<input type="password" name="password" id="password" />
<button type="button">登陆</button>
</form>
</body>
<style type="text/css">
#login-form {
display: none;
}
#login-form:target {
display: block;
}
/* 设置选中文本的前景色与背景色
*/
input::selection {
color: crimson;
background-color: cyan;
}
</style>
<title></title>
</head>
<body>
<button onclick="location='#login-form'">
点击登陆
</button>
<form action="" method="post" id="login-form">
<label for="email">邮箱:</label>
<input type="email" name="email" id="email" />
<br />
<label for="password">密码:</label>
<input type="password" name="password" id="password" />
<button type="button">登陆</button>
</form>
</body>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
/*排除.hello类
ul > li:not(.hello) {
color: pink;
}
*/
/*排除第5个*/
ul > li:not(:nth-of-type(5)) {
color: pink;
}
</style>
</head>
<body>
<ul>
<li class="zhu">你好朱老师</li>
<li class="zhu">你好朱老师</li>
<li class="zhu">你好朱老师</li>
<li class="zhu">你好朱老师</li>
<li class="hello">你好朱老师</li>
<li class="zhu">你好朱老师</li>
<li class="zhu">你好朱老师</li>
<li class="zhu">你好朱老师</li>
<li class="zhu">你好朱老师</li>
<li class="zhu">你好朱老师</li>
</ul>
</body>
</html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
ul > li:not(:nth-of-type(7)) {
color: pink;
}
ul > li:not(.hello) {
color: pink;
}
ul::before {
content: "你好这里before增加一个头部伪元素";
}
ul::after {
content: "你好这里是after增加一个尾部伪元素";
}
</style>
</head>
<body>
<ul>
<li class="zhu">你好朱老师</li>
<li class="zhu">你好朱老师</li>
<li class="zhu">你好朱老师</li>
<li class="zhu">你好朱老师</li>
<li class="hello">你好朱老师</li>
<li class="zhu">你好朱老师</li>
<li class="zhu">你好朱老师</li>
<li class="zhu">你好朱老师</li>
<li class="zhu">你好朱老师</li>
<li class="zhu">你好朱老师</li>
</ul>
</body>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号