只是第一个出现了变化,有颜色有三角形,但是后面4个无论怎么点都没变化即使是移到上面也毫无变化,怎么回事?.st-container input:checked + a,.st-container input:checked:hover + a{ background-color: #821134; /*设置被选中了颜色恒定不变*/}.st-container input:checked + a:after{ content:""; width:0; height:0; overflow: hidden; border: 20px solid transparent; border-bottom-color: #821134; position:absolute; bottom: 100%; left:50%; margin-left: -20px; /*使三角形居中的方法*/ /*温习下:after的用法*/}.st-container input:hover + a{ background: #AD244F; /*鼠标滑过的背景颜色发生变化*/}
3 回答
stone310
TA贡献361条经验 获得超191个赞
试了下代码能出
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8">
<style>
.st-container {
height: 100px;
width: 200px;
position: relative;
}
.st-container input:checked + a,
.st-container input:checked:hover + a {
background-color: #821134;
/*设置被选中了颜色恒定不变*/
}
.st-container input:checked + a:after {
content: "";
width: 0;
height: 0;
overflow: hidden;
border: 20px solid transparent;
border-bottom-color: #821134;
position: absolute;
bottom: 100%;
left: 50%;
margin-left: -20px;
/*使三角形居中的方法*/
/*温习下:after的用法*/
}
.st-container input:hover + a {
background: #AD244F;
/*鼠标滑过的背景颜色发生变化*/
}
</style>
</head>
<body>
<div class="st-container">
<input type="checkbox"/>
<a>sdfasdfsdf</a>
</div>
<div class="st-container">
<input type="checkbox"/>
<a>sdfasdfsdf</a>
</div>
<div class="st-container">
<input type="checkbox"/>
<a>sdfasdfsdf</a>
</div>
<div class="st-container">
<input type="checkbox"/>
<a>sdfasdfsdf</a>
</div>
</body>
</html>- 3 回答
- 0 关注
- 2181 浏览
添加回答
举报
0/150
提交
取消
