AnApprentice AnApprentice - 10 months ago 52
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?

Thanks



.navbar-brand {
height: 40px;
width: 182px;
text-indent: 100%;
overflow: hidden;
white-space: nowrap;
background: url('https://www.sketchappsources.com/resources/source-image/twitterlogo_1x.png') 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="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" 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>
</button>
<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>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<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>
</form>
</div>
</nav>
</div>




Ian Ian
Answer Source

Use

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.

JSfiddle.. https://jsfiddle.net/ataue61h/2/

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