我正在对 a
标签应用悬停效果,只是想知道是否可以仅将 css 应用于那些内部没有图像的标签
<a href="#">link</a>
<a href="#"><img src='abc.png'></a>
a:hover,a:focus,.text-link:hover,.text-link:focus{
background: #551011;
color: #8b6508;
}
这是我试过但没用的
a:not(img):hover,a:not(img):focus,.text-link:not(img):hover,.text-link:not(img):focus{
background: #551011;
color: #8b6508;
}
我做错了什么
最佳答案
请这样尝试:
<!doctype html>
<html>
<head>
<style>
a:not(.myimage):hover,a:not(.myimage):focus,.text-link:not(.myimage):hover,.text-link:not(.myimage):focus{
background: #551011;
color: #8b6508;
}
</style>
</head>
<body>
<a href="#">link</a>
<a class="myimage" href="#"><img src='abc.png'></a>
</body>
</html>
关于html - 标签的 css 但不是包含图像的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36104722/