【发布时间】:2020-08-31 23:21:44
【问题描述】:
我正在使用 css 过渡在悬停期间使用 box-shadow inset 填充我的按钮。
我也在使用过渡来改变悬停期间按钮的边框半径。
当我悬停时,会发生过渡,但我在按钮的每个内角都留下了一条未填充的细曲线。
HTML
<div class="container">
<button type="button" id="upSwipe">Up Swipe</button>
<button type="button" id="downSwipe">Down Swipe</button>
<button type="button" id="leftSwipe">Left Swipe</button>
<button type="button" id="rightSwipe">Right Swipe</button>
</div>
CSS:
* {
margin: 0;
padding: 0;
background: none;
}
.container {
position: absolute;
background: black;
background-size: cover;
height: 100vh;
width: 100vw;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
button {
height: 200px;
width: 200px;
margin: 20px;
background: none;
border: 10px solid orange;
border-radius: 20px;
color: orange;
font-size: 30px;
box-shadow: inset 0 0 0 orange;
transition: 0.5s ease;
}
#upSwipe:hover {
box-shadow: inset 0 -7em 0 orange;
color: black;
border-radius: 30px;
}
* {
margin: 0;
padding: 0;
background: none;
}
.container {
position: absolute;
background: black;
background-size: cover;
height: 100vh;
width: 100vw;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
button {
height: 200px;
width: 200px;
margin: 20px;
background: none;
border: 10px solid orange;
border-radius: 20px;
color: orange;
font-size: 30px;
box-shadow: inset 0 0 0 orange;
transition: 0.5s ease;
}
#upSwipe:hover {
box-shadow: inset 0 -7em 0 orange;
color: black;
border-radius: 30px;
}
这是我的尝试: https://codepen.io/thomaswanless/pen/XWmPePe
感谢您的帮助!
【问题讨论】:
-
只需从悬停 CSS 中删除
border-radius属性,或者根据按钮半径将border-radius减少到20px -
您可以将
border:none设置为所有:hover类。