我有一个问题,需要在after伪类选择器上实现活动图标选择器。以下是我的代码:
<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>
请为我建议一种使用伪类选择器:after来实现活动选择器的方法。提前感谢您的帮助。
pointer-events: none;
,并在伪元素上放置pointer-events: auto;
。这将导致伪元素样式仅在激活伪元素时发生,如果激活父元素则不会发生任何事情。 - BigMacAttack