我试图在活动状态下按下一个斜角按钮。我希望过渡过程足够平稳,但问题是我不知道如何实现这种平稳。我所取得的成就如下:
.button {
background-color: #ff962c;
border-radius: 10px;
width: 25%;
text-align: center;
color: #FFFFFF;
padding: 10px;
font-family: 'Source Sans Pro', sans-serif;
display: inline-block;
font-size: 20px;
box-shadow: inset 2px 2px 2px rgba(255, 255, 255, .4), inset -2px -2px 2px rgba(0, 0, 0, .4);
}
.button:active {
border: 1px solid #ff962c;
background-color: #ffa346;
box-shadow: inset 2px 2px 2px rgba(0, 0, 0, .8), inset -1px -1px 1px rgba(255, 255, 255, .4);
}
.button:hover {
background-color: #ffa346;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css" rel="stylesheet" />
<a href="" id="upload" class="button">
<i class="fa fa-cloud-upload fa-lg fa-align-center" aria-hidden="true"></i>
</a>
<a href="" id="view" class="button">
<i class="fa fa-eye fa-lg fa-align-center" aria-hidden="true"></i>
</a>
你可以添加css过渡。确切地说:transition: box-shadow .2s ease-in-out;
。我建议只改变过渡的特定属性,特别是当我们谈论框阴影和其他沉重的效果。
.button {
background-color: #ff962c;
border-radius: 10px;
width: 25%;
text-align: center;
color: #FFFFFF;
padding: 10px;
font-family: 'Source Sans Pro', sans-serif;
display: inline-block;
font-size: 20px;
box-shadow: inset 2px 2px 2px rgba(255, 255, 255, .4), inset -2px -2px 2px rgba(0, 0, 0, .4);
transition: box-shadow .2s ease-in-out;
}
.button:active {
box-shadow: inset 2px 2px 2px rgba(0, 0, 0, .8), inset -1px -1px 1px rgba(255, 255, 255, .4);
}
.button:hover {
background-color: #ffa346;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css" rel="stylesheet" />
<a href="" id="upload" class="button">
<i class="fa fa-cloud-upload fa-lg fa-align-center" aria-hidden="true"></i>
</a>
<a href="" id="view" class="button">
<i class="fa fa-eye fa-lg fa-align-center" aria-hidden="true"></i>
</a>
您的意思是这样,仅仅使用transitions
吗?
看看这个链接,它可能会很有用:hover.css
.button {
background-color: #ff962c;
border-radius: 10px;
width: 25%;
text-align: center;
color: #FFFFFF;
padding: 10px;
font-family: 'Source Sans Pro', sans-serif;
display: inline-block;
font-size: 20px;
box-shadow: inset 2px 2px 2px rgba(255, 255, 255, .4), inset -2px -2px 2px rgba(0, 0, 0, .4);
-webkit-transition: all .1s ease;
-moz-transition: all .1s ease;
-o-transition: all .1s ease;
transition: all .1s ease;
}
.button:active {
border: 1px solid #ff962c;
background-color: #ffa346;
box-shadow: inset 2px 2px 2px rgba(0, 0, 0, .8), inset -1px -1px 1px rgba(255, 255, 255, .4);
}
.button:hover {
background-color: #ffa346;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css" rel="stylesheet" />
<a href="" id="upload" class="button">
<i class="fa fa-cloud-upload fa-lg fa-align-center" aria-hidden="true"></i>
</a>
<a href="" id="view" class="button">
<i class="fa fa-eye fa-lg fa-align-center" aria-hidden="true"></i>
</a>
试试这个
.button {
background-color: #ff962c;
border-radius: 10px;
width: 25%;
text-align: center;
color: #FFFFFF;
padding: 10px;
font-family: 'Source Sans Pro', sans-serif;
display: inline-block;
font-size: 20px;
box-shadow: inset 2px 2px 2px rgba(255, 255, 255, .4), inset -2px -2px 2px rgba(0, 0, 0, .4);
}
.button:active {
border: 1px solid #ff962c;
background-color: #ffa346;
box-shadow: inset 2px 2px 2px rgba(0, 0, 0, .8), inset -1px -1px 1px rgba(255, 255, 255, .4);
-webkit-transition: all .1s ease;
-moz-transition: all .1s ease;
-o-transition: all .1s ease;
transition: all .1s ease;
}
.button:hover {
background-color: #ffa346;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css" rel="stylesheet" />
<a href="#" id="upload" class="button">
<i class="fa fa-cloud-upload fa-lg fa-align-center" aria-hidden="true"></i>
</a>
<a href="#" id="view" class="button">
<i class="fa fa-eye fa-lg fa-align-center" aria-hidden="true"></i>
</a>