我试图让我的导航栏标题标识在点击/释放时轻松进出。
目前,当您点击徽标时,图像会正常放松,但是当您释放时它会快速恢复,并且不会恢复到正常尺寸。
CSS3我做错了什么?
由于
.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>
&#13;
答案 0 :(得分:1)
使用
transition: ease-in-out all .5s
而不是
transition-timing-function
和transition
目前你只是放松,而不是放松。在这种情况下,您必须为元素设置动画,而不是:active。
JSfiddle .. https://jsfiddle.net/ataue61h/2/