user3786102 user3786102 - 3 months ago 7x
HTML Question

Bootstrap btn-primary appear on hover

I think this should be relatively easy to do but I just can't get it to work. I have my btn centered nicely over my image using display flex. I want the btn to appear when the user hovers over the image, and when they move the cursor off the image it disappears. I'm also wanting to add a subtle ease-in-out effect so it transitions smoothly. Any help is much appreciated. Here is my css and html.


<div class="row">
<div class="col-md-4">
<div class="imgAbout">
<img src="" 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>

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


#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;


Add to your CSS next lines:

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