Ana*_*ndh 1 html css css-selectors pseudo-element
我有一个问题要在伪选择器后的活动图标选择器上实现.以下是我尝试过的代码.
<html>
<head>
<style type="text/css">
.btn{
width:25%;
}
.name{
background: #fff;
color: #000;
text-align: center;
height: 35px;
line-height: 35px;
font-size: 18px;
border: 1px solid;
}
.name:after{
content: "";
position: absolute;
left: 210px;
top: 19px;
background-image: url('dark.png');
width: 15px;
height: 15px;
background-size: 100% auto;
}
.name:after:active{
background-image: url('light.png');
}
</style>
</head>
<body>
<div class="btn name">Submit</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)


建议我使用after伪选择器实现活动选择器的方法.提前致谢.
伪元素需要最后:
.name:active:after{
background-image: url('light.png');
}
Run Code Online (Sandbox Code Playgroud)
如果您只想在激活伪元素时更改伪元素样式,那是不可能的.请参阅此答案以获得解释.