英文:
Change a picture with a hover in css
问题
大家好
我在开发一个HTML文档中有一个卡片,它有一个设置的图像,但我想在鼠标悬停时将图像更改为另一个图像,当我移除鼠标时它恢复正常。
我该如何做到这一点,我已经阅读了其他帖子,但它们改变了卡片的背景,我希望在不修改卡片本身的情况下更改图像。
我尝试在卡片内部更改图像。
英文:
`Hello everyone
I have this card in an html document that I am developing, it has an image set but I want it to change the image to another when I mouse over it and when I remove it it returns to normal.
How can I do it, I have read other posts about it but they change the background of the card and I would like to change the image without modifying the card itself
<div class="container">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-6">
<!-- 1 Alexis -->
<div class="col" style="margin-bottom: 2rem;">
<div class="card card-team h-100">
<div style="text-align: center;">
<img src="./src/img/nosotros/AlexisSanchez.jpeg"
style="width: 150px; height: 150px; margin-top: 1rem;box-shadow: 2px 2px 2px 1px rgba(0, 0, 0, 0.1);"
class="img-fluid rounded" alt="Alexis">
</div>
<div class="card-body">
<div class="title__card">
<span>Alexis Sánchez León</span>
</div>
<div class="subtitle__card">
<span>Desarrollador Java | Ing. Industrial</span>
</div>
<p class="card-text" style="text-align: justify;">Soy un desarrollador Java, enfocado en
el frontend y en la gestión de proyectos con el marco de trabajo SCRUM para la
entrega de valor oportuna.</p>
</div>
<!-- redes sociales -->
<div class="social__media card-footer ">
<a href="https://github.com/ALEXISSL10" target="_blank"><span><i
class="bi bi-github social__media__icon"></i></span></a>
<a href="https://www.linkedin.com/in/alexis-s%C3%A1nchez-le%C3%B3n"
target="_blank"><span><i class="bi bi-linkedin social__media__icon"></i></span></a>
</div>
</div>
</div>
`
I try to change the image inside the card
答案1
得分: 0
<!-- 开始代码片段:js 隐藏:false 控制台:true babel:false -->
<!-- 语言:lang-css -->
.static {
position:absolute;
background: white;
}
.static:hover {
opacity:0;
}
<!-- 语言:lang-html -->
<div class="col" style="margin-bottom: 2rem;">
<div class="card card-team h-100">
<div style="text-align: center;">
<img src="src/img/nosotros/alexis-normal.jpg" style="width: 150px; height: 150px; margin-top: 1rem;box-shadow: 2px 2px 2px 1px rgba(0, 0, 0, 0.1);"
class="img-fluid rounded static" alt="Alexis"><img class="active" src="src/img/nosotros/alexis-pintado.jpg" style="width: 150px; height: 150px; margin-top: 1rem;box-shadow: 2px 2px 2px 1px rgba(0, 0, 0, 0.1);"
class="img-fluid rounded" alt="Alexis">
</div>
<div class="card-body">
<div class="title__card">
<span>Alexis Sánchez León</span>
</div>
<div class="subtitle__card">
<span>Desarrollador Java | Ing. Industrial</span>
</div>
<p class="card-text" style="text-align: justify;">Soy un desarrollador Java, enfocado en
el frontend y en la gestión de proyectos con el marco de trabajo SCRUM para la
entrega de valor oportuna.</p>
</div>
<!-- redes sociales -->
<div class="social__media card-footer ">
<a href="https://github.com/ALEXISSL10" target="_blank"><span><i
class="bi bi-github social__media__icon"></i></span></a>
<a href="https://www.linkedin.com/in/alexis-s%C3%A1nchez-le%C3%B3n"
target="_blank"><span><i class="bi bi-linkedin social__media__icon"></i></span></a>
</div>
</div>
</div>
<!-- 结束代码片段 -->
英文:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.static {
position:absolute;
background: white;
}
.static:hover {
opacity:0;
}
<!-- language: lang-html -->
<div class="col" style="margin-bottom: 2rem;">
<div class="card card-team h-100">
<div style="text-align: center;">
<img src="src/img/nosotros/alexis-normal.jpg" style="width: 150px; height: 150px; margin-top: 1rem;box-shadow: 2px 2px 2px 1px rgba(0, 0, 0, 0.1);"
class="img-fluid rounded static" alt="Alexis"><img class="active" src="src/img/nosotros/alexis-pintado.jpg" style="width: 150px; height: 150px; margin-top: 1rem;box-shadow: 2px 2px 2px 1px rgba(0, 0, 0, 0.1);"
class="img-fluid rounded" alt="Alexis">
</div>
<div class="card-body">
<div class="title__card">
<span>Alexis Sánchez León</span>
</div>
<div class="subtitle__card">
<span>Desarrollador Java | Ing. Industrial</span>
</div>
<p class="card-text" style="text-align: justify;">Soy un desarrollador Java, enfocado en
el frontend y en la gestión de proyectos con el marco de trabajo SCRUM para la
entrega de valor oportuna.</p>
</div>
<!-- redes sociales -->
<div class="social__media card-footer ">
<a href="https://github.com/ALEXISSL10" target="_blank"><span><i
class="bi bi-github social__media__icon"></i></span></a>
<a href="https://www.linkedin.com/in/alexis-s%C3%A1nchez-le%C3%B3n"
target="_blank"><span><i class="bi bi-linkedin social__media__icon"></i></span></a>
</div>
</div>
</div>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论