Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css3 animation on hover

Tags:

html

jquery

css

I would like to make effect with css3 on hover.

I have one button let say AB when mouse hover on it. It should expand lets say A becomes ALL and B becomes BALL with the transition effect. On hover out back into there original state AB.

I achieve this effect with CSS3 but not what I am looking for.

Here is the full code on jsfiddle. https://jsfiddle.net/magtechpro/8auz2nx3/4/

As you can see the animation is not smooth on AB. I want smooth animation. I am stuck here.

Your help will be highly appreciate.

Many thanks

@-webkit-keyframes fadeIn {
    from { opacity: 0; }
      to { opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
      to { opacity: 1; }
}
mark {
  background-color: transparent;
}



a span.visual , a span.merchandising {
    display: none;
}

a:hover span.visual , a:hover span.merchandising{
    display: inline-block;

    -webkit-animation: fadeIn 2s;
    animation: fadeIn 2s;
}
like image 422
Rana Hussain Avatar asked Feb 17 '26 01:02

Rana Hussain


1 Answers

You need to animate the width.

No need to use keyframes to do this, just add the new parameters in the hover, and adds transition to smooth animation

mark {
  background-color: transparent;
}

a span.visual , 
a span.merchandising {
    display: inline-block;
    width:0;
    opacity: 0;

    -webkit-transition: all 0.4s linear; /* Safari */
    transition: all  0.4s linear;
}

a:hover span.visual, 
a:hover span.merchandising {
  opacity: 1; 
  width:30px;
}

Working example: https://jsfiddle.net/8auz2nx3/6/



Note:

You can use easings to give a more cool animation.

To use easing choose what animation you whant from the link above and in the next page you will see in red the code to inter on the property.


enter image description here


See here in action.

like image 161
Helder Vilela Avatar answered Feb 19 '26 01:02

Helder Vilela



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!