AnApprentice AnApprentice - 6 months ago 31
CSS Question

CSS3, how to get a button press to ease in and ease out?

I'm trying to get my nav-bar header logo to ease in and out on click/release.

Currently, when you click the logo, the image eases correctly but when you release it snaps back and doesn't ease back into the normal size.

What am I doing wrong with the CSS3?


.navbar-brand {
height: 40px;
width: 182px;
text-indent: 100%;
overflow: hidden;
white-space: nowrap;
background: url('') no-repeat left center;
background-size: auto 40px;
transform: scale(1, 1);
transition-timing-function: ease-in;
transition: 0.2s;

.navbar-brand:active {
transition-timing-function: ease-out;
transition: .5s;
transform: scale(.95, .95);

<link href="" rel="stylesheet"/>
<div class="bd-example" data-example-id="">
<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
<a class="navbar-brand" href="#">Navbar</a>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>

Ian Ian
Answer Source


transition: ease-in-out all .5s

instead of

transition-timing-function and transition

At the moment you are only easing in, not out. You must animate the element in this case, not the :active.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download