How to fix popping on hover?

74 views Asked by At

hope you are all well. How do i fix the popping on image hover? I need it to slowly go large. as you can see the large image just fades.

I have attached a nice example to explain this more.enter image description here

Any help would be grateful here. Thx yummi

/*............ right-column ............*/

.right-column {
  position: absolute;
}


/*......... crossfade on buttons .........*/

#hover img {
  -o-transition: .3s;
  -ms-transition: .3s;
  -moz-transition: .3s;
  -webkit-transition: .3s;
  position: absolute;
}

.nohover {
  opacity: 0;
}

a:hover .hover {
  opacity: 0;
}

a:hover .nohover {
  opacity: 1;
}


/*................ bevels ................*/

img.bevel {
  border-radius: 20px;
}

img#bevel {
  border-radius: 20px;
}


/*............. pop on hover .............*/

#pop img {
  transition: .5s ease
}

#pop img:hover {
  -webkit-transform: scale(1.15);
  -ms-transform: scale(1.15);
  transform: scale(1.15);
  transition: 0.5s ease;
}
<div class="right-column" id="pop" align="center">
  <div>
    <a id="hover" href="gallery.html"><img src="http://wizzfree.com/pix/vid0.jpg" width="120" id="bevel" class="nohover"><img src="http://wizzfree.com/pix/vid0b.jpg" width="120" id="bevel" class="hover"></a>
  </div>

2

There are 2 answers

1
Roko C. Buljan On BEST ANSWER

Using only one image and CSS filter:

.btnImg {
  display: inline-block;
  width: 120px; height: 80px;
  border-radius: 20px;
  overflow: hidden;
  transition: transform .3s;
}
.btnImg img {
  width: inherit; height: inherit;
  object-fit: cover;
  transition: filter .3s;
  transform: scale(1.05);
  filter: blur(3px);
  backface-visibility: hidden;
}
.btnImg:hover {
  transform: scale(1.16);
}
.btnImg:hover img {
  filter: blur(0);
}
<a class="btnImg" href="gallery.html">
  <img src="http://wizzfree.com/pix/vid0.jpg">
</a>

0
Ori Drori On

The main problem is that the scale was applied to the currently hovered image, which disappears due to opacity: 0 when hovered.

The scale transform, and the transition should apply to all images under a#hover.

Note: I've cleaned up your CSS. No need for browser prefixes for transforms, and transitions, unless you need to support really old browsers. Check your target browsers before adding prefixes.

/*......... crossfade on buttons .........*/

.hover img {
  position: absolute;
  transition: all 0.5s ease;
}

.nohover {
  opacity: 0;
}

.hover:hover img {
  transform: scale(1.15);
}

.hover:hover .hover {
  opacity: 0;
}

.hover:hover .nohover {
  opacity: 1;
}

/*................ bevels ................*/

.bevel {
  border-radius: 20px;
}
<a class="hover" href="gallery.html">
  <img src="http://wizzfree.com/pix/vid0.jpg" width="120" class="nohover bevel">
  <img src="http://wizzfree.com/pix/vid0b.jpg" width="120" class="hover bevel">
</a>

If you don't need to support IE, you can get the same effect with a single image, and the CSS blur filter:

/*......... crossfade on buttons .........*/

.hover img {
  position: absolute;
  transition: all 0.5s ease;
  filter: blur(3px);
}

.hover:hover img {
  transform: scale(1.15);
  filter: blur(0);
}

/*................ bevels ................*/

.bevel {
  border-radius: 20px;
}
<a class="hover" href="gallery.html">
  <img src="http://wizzfree.com/pix/vid0.jpg" width="120" class="bevel">
</a>