所以我一直在一个网站上点击图片,但我似乎无法得到...:hover
的权利。我希望图片可以用0.1不透明的白色覆盖。CSS:改变颜色悬停
<html>
<head>
<style>
body {padding: 0; margin: 0;}
img {
margin-top: -10px;
width: 100%;
height: auto;
}
a:hover {
background-color: rgba(255, 255, 255, 0.1);
}
#asca:hover {background-color: rgba(255, 255, 255, 0.1);}
#fhca:hover {background-color: rgba(255, 255, 255, 0.1);}
#asca img:hover {background-color: rgba(255, 255, 255, 0.1);}
#fhca img:hover {background-color: rgba(255, 255, 255, 0.1);}
</style>
</head>
<body>
<a id="asca" href="asc.php">
<img src="Pictures/chevcorvette4kp.png" width="4096" height="900" alt="ascpic">
</a>
<a id="fhca" href="fhc.php">
<img src="Pictures/fhyper.png" width="4096" height="900" alt="fhcpic">
</a>
</body>
</html>
正如你所看到的,我真的试图在悬停时改变所有颜色,但它似乎不起作用。
当然,它不起作用,因为你实际上没有在图像的前面放置任何“over”,你只是改变图像背景颜色。您需要首先在图像上放置一个(伪)元素,然后您可以修改该元素的背景。 – CBroe