gpt4 book ai didi

html - Bootstrap btn-primary 出现在悬停时

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

我认为这应该相对容易做到,但我就是无法让它发挥作用。我使用 display flex 将 btn 很好地居中放置在我的图像上。当用户将鼠标悬停在图像上时,我希望 btn 出现,当他们将光标从图像上移开时,它会消失。我还想添加一个微妙的缓入缓出效果,以便平稳过渡。任何帮助深表感谢。这是我的 css 和 html。

HTML

<div class="row">
<div class="col-md-4">
<div class="imgAbout">
<img src="http://placehold.it/580x410" class="img-responsive" alt="Neil Elmouchi Bio">

<div class="center-container">
<a class="btn btn-sm btn-primary" href="bios/teamBioNeil.html">View More</a>
</div>
</div>

<h1>Name</h1>
<h3>Chairman &amp; CEO<br>
Senior Wealth Advisor</h3>
</div> <!-- end col-md-4 -->
</div>

CSS

#about img {
margin: 0 auto;
}

.imgAbout {
position: relative;
}

.imgAbout img {
display: block;
height: auto;
}

.center-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
}

最佳答案

将下一行添加到您的 CSS:

.imgAbout .center-container .btn {
visibility: hidden;
opacity: 0;
transition: visibility 0s, opacity 0.5s linear;
}
.imgAbout:hover > .center-container .btn {
visibility:visible;
opacity: 1;
}

关于html - Bootstrap btn-primary 出现在悬停时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38425299/

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