1

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.

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;
}
user3786102
  • 145
  • 6
  • 19

1 Answers1

2

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 { 
  visibility:visible;
  opacity: 1;
}