3 回答

TA貢獻1804條經驗 獲得超3個贊
您需要為灰度選擇未懸停的圖像:img:not(:hover)
.inst__img {
width: 11%;
margin-left: 10%;
display: inline-block;
}
.inst__img img{
width: 100%;
}
.global__inst:hover img:not(:hover) {
filter: grayscale(1);
-webkit-filter: grayscale(1);
}
<section class="global__inst">
<div class="inst__img">
<img src="https://media.wired.com/photos/598e35994ab8482c0d6946e0/master/w_2560%2Cc_limit/phonepicutres-TA.jpg" alt="">
<span>vi</span>
</div>
<div class="inst__img">
<img src="https://media.wired.com/photos/598e35994ab8482c0d6946e0/master/w_2560%2Cc_limit/phonepicutres-TA.jpg" alt="">
<span>vi</span>
</div>
<div class="inst__img">
<img src="https://media.wired.com/photos/598e35994ab8482c0d6946e0/master/w_2560%2Cc_limit/phonepicutres-TA.jpg" alt="">
<span>vi</span>
</div>
<div class="inst__img">
<img src="https://media.wired.com/photos/598e35994ab8482c0d6946e0/master/w_2560%2Cc_limit/phonepicutres-TA.jpg" alt="">
<span>vi</span>
</div>
</section>

TA貢獻1871條經驗 獲得超13個贊
用這個:
.inst__img {
width: 11%;
margin-left: 10%;
display: inline-block;
}
.inst__img img {
width: 100%
}
.global__inst:hover .inst__img img {
filter: grayscale(100%);
}
.inst__img:hover img {
filter: none !important;
}
<section class="global__inst">
<div class="inst__img">
<img src="https://media.wired.com/photos/598e35994ab8482c0d6946e0/master/w_2560%2Cc_limit/phonepicutres-TA.jpg" alt="">
<span>vi</span>
</div>
<div class="inst__img">
<img src="https://media.wired.com/photos/598e35994ab8482c0d6946e0/master/w_2560%2Cc_limit/phonepicutres-TA.jpg" alt="">
<span>vi</span>
</div>
<div class="inst__img">
<img src="https://media.wired.com/photos/598e35994ab8482c0d6946e0/master/w_2560%2Cc_limit/phonepicutres-TA.jpg" alt="">
<span>vi</span>
</div>
<div class="inst__img">
<img src="https://media.wired.com/photos/598e35994ab8482c0d6946e0/master/w_2560%2Cc_limit/phonepicutres-TA.jpg" alt="">
<span>vi</span>
</div>
</section>

TA貢獻1805條經驗 獲得超9個贊
請嘗試以下。初始所有列表圖像將是黑色的,懸停的圖像可以隨意顯示
.inst__img{
border:2px solid red;
background: black; opacity:.5
}
.inst__img:hover{
border:2px solid red;
background: white;
opacity:1
}
添加回答
舉報