Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS ease in and out on hover

I have a simple div that is round with a border-radius of 50%. On hover the border radius changes to zero. I have used the following css code which works perfectly.

.design-box {
  width: 100%;
  height: 250px;
  margin: 100px auto;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  position: relative;
}

.design-box:hover {
  border-radius: 0;
  -webkit-transition: all 1s ease;
  transition: all 1s ease;
}
<div class="design-box"></div>

What I would like to happen is that when the div is no longer hovered I would like the transition to ease out and slowly transform back to the original border-radius of 50%. I cant quite get it to work, am I missing a simple step here?

Thank you

like image 205
rufus Avatar asked Dec 21 '16 16:12

rufus


People also ask

What is CSS ease-in-out?

ease-in - specifies a transition effect with a slow start. ease-out - specifies a transition effect with a slow end. ease-in-out - specifies a transition effect with a slow start and end.


1 Answers

Put transition only on the normal state:

.design-box {
  transition: all 1s ease;
}

Have a look at the snippet below:

.design-box {
  width: 100%;
  height: 250px;
  margin: 100px auto;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  position: relative;
  transition: all 1s ease;
}

.design-box:hover {
  border-radius: 0;
}
<div class="design-box"></div>
like image 91
Saurav Rastogi Avatar answered Sep 29 '22 10:09

Saurav Rastogi