这是我的代码:
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown:hover .dropdown-content {
display: block;
}
#image1:hover {
filter: brightness(50%);
}
.desc {
padding: 15px;
text-align: center;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h2>Dropdown Image</h2>
<p>Move the mouse over the image below to open the dropdown content.</p>
<div class="dropdown">
<img id="image1" src="https://www.w3schools.com/css/img_5terre.jpg" alt="Cinque Terre" width="100" height="50">
<div class="dropdown-content">
<img src="https://www.w3schools.com/css/img_5terre.jpg" alt="Cinque Terre" width="300" height="200">
<div class="desc">Beautiful Cinque Terre</div>
</div>
</div>
</body>
</html>
当你运行它并将鼠标悬停在小照片上时,你可以看到它的一个大版本出现了(小版本变暗了)。尽管如此,当你把鼠标从较小的版本移到较大的版本时,小照片会恢复正常。
有人能给我解释一下,当光标放在小照片上或是用CSS的大照片上时,我怎样才能让小照片更暗(选中)?
提前非常感谢。