如何将此按钮悬停效果从当前自上而下反转到下顶?
.btn-1 {
position: relative;
border-width: 2px;
border-color: #4285f4;
color: #4285f4;
background-color: transparent;
}
.slide-btn, .slide-btn::after {
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.slide-btn::before, .slide-btn::after {
background: #4285f4;
content: '';
position: absolute;
z-index: -1;
}
.btn-1::after {
height: 0;
left: 0;
top: 0;
width: 100%;
}
.btn-1:hover:after {
height: 100%;
}

<button class="btn-1 slide-btn">Button 1</button>
&#13;
玩了很长时间,例如改为.btn-1 :: after {height:100%; }和.btn-1 :: after {height:0; ... ...它给了我倒置效果,但反色。
答案 0 :(得分:2)
在.btn-1 ::之后从上到下更改 https://jsfiddle.net/rp042h6j/
.btn-1::after {
height: 0;
left: 0;
bottom: 0;
width: 100%;
}
答案 1 :(得分:1)
在.btn-1::after
将top
更改为bottom
:
.btn-1 {
position: relative;
border-width: 2px;
border-color: #4285f4;
color: #4285f4;
background-color: transparent;
}
.slide-btn,
.slide-btn::after {
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.slide-btn::before,
.slide-btn::after {
background: #4285f4;
content: '';
position: absolute;
z-index: -1;
}
.btn-1::after {
height: 0;
left: 0;
bottom: 0;
width: 100%;
}
.btn-1:hover:after {
height: 100%;
}
<button class="btn-1 slide-btn">Button 1</button>