img__text当用户将鼠标悬停在 上时,我想将不透明度增加到 1 text__container。text__container我已经尝试通过严格的 CSS 来实现这一点,方法是像这样影响孩子,#text__container ~ .img__text然后应用所需的 CSS 效果。
索引.html
<div class="gallery__container">
<div>
<img class="gallery__img" src="./images/image1.png" alt="">
<div id="text__container">
<span class="img__text">Shake & Shot</span>
</div>
</div>
<div>
<img class="gallery__img" src="./images/image2.png" alt="">
<div id="text__container">
<span class="img__text">It's On</span>
</div>
</div>
<div>
<img class="gallery__img" src="./images/image3.png" alt="">
<div id="text__container">
<span class="img__text">Shake & Shot</span>
</div>
</div>
<div>
<img class="gallery__img" src="./images/image4.png" alt="">
<div id="text__container">
<span class="img__text">Shake & Shot</span>
</div>
</div>
<div>
<img class="gallery__img" src="./images/image5.png" alt="">
<div id="text__container">
<span class="img__text">Shake & Shot</span>
</div>
</div>
<div>
<img class="gallery__img" src="./images/image6.png" alt="">
<div id="text__container">
<span class="img__text">Shake & Shot</span>
</div>
</div>
</div>
风格.scss
//Gallery
.gallery__container {
margin-top: 5%;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
div {
background-color: #000;
width: 49%;
margin: 0 0 2% 0;
height: 665px;
display: grid;
img {
grid-column: 1;
grid-row: 1;
height: 100%;
width: 100%;
z-index: 1;
align-content: center;
transition: 0.8s ease-out;
opacity: 1;
&:hover {
transition: 0.8s ease-in;
cursor: pointer;
opacity: 0.5;
}
}
开满天机
相关分类