gpt4 book ai didi

css - 更改 div 内图像的不透明度,同时在不更改不透明度的情况下更改其下方文本的颜色

转载 作者:太空宇宙 更新时间:2023-11-04 08:59:01 25 4
gpt4 key购买 nike

这可能非常简单,但我就是不明白。我试图让它在你将鼠标悬停在整个 div 上时改变图像的不透明度,同时改变它下面字体的颜色(但不改变字体的不透明度)。

看我这里的意思的例子---> http://www.golfcarsofdallas.com/cart-finder/new-carts/club-car/commercial/

这是我的代码,但它只会在我将鼠标悬停在文本上时改变颜色,而在我将鼠标悬停在图像上时改变不透明度。不是整个 div。

.showroom-models-big img {
opacity: 1;
transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
-webkit-transition: all .2s ease-in-out;
}

.showroom-models-big p {
margin-top: -40px;
font-weight: 600;
text-align: center;
}

.showroom-models-big a {
color: #000000;
transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
-webkit-transition: all .2s ease-in-out;
}

.showroom-models-big img:hover {
opacity: 0.7;
}
.showroom-models-big a:hover {
color: #35c411;
}

最佳答案

您必须将 :hover 设置为 div,后跟其中的元素,就像这个例子一样。

.container {
background: #fff;
display:inline-block;
text-align: center;
}
.container:hover img {
opacity: .6;
}
.container:hover p {
color: blue;
}
<div class="container">
<img src="http://www.golfcarsofdallas.com/wp-content/uploads/streetlegal.jpg" alt="">
<p>Some text</p>
</div>

关于css - 更改 div 内图像的不透明度,同时在不更改不透明度的情况下更改其下方文本的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42894363/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com