有必要实现“斜角”按钮的填充。为此,我使用before
,这是一个旋转一定角度的矩形,当您将鼠标悬停在按钮上时,其大小会增加。
.auth {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.button {
position: relative;
display: inline-block;
vertical-align: top;
padding: 20px 45px;
font-size: 13px;
font-weight: 600;
color: #fff;
text-decoration: none;
text-transform: uppercase;
text-align: center;
color: #191919;
/* background-color: #fff; */
background-color: transparent;
border: 1px solid #191919;
border-radius: 5px;
cursor: pointer;
outline: 0;
transition: background-color 0.2s linear, color 0.2s linear;
}
.button:hover {
color: #fff;
/* background-color: #191919; */
}
.button::before {
position: absolute;
left: -50%;
top: -100%;
transform: rotate(-10deg);
z-index: -1;
display: block;
width: 100%;
height: 100%;
overflow: hidden;
content: '';
background-color: red;
transition: width 0.2s linear, height 0.2s linear;
}
.button:hover::before {
width: 160%;
height: 250%;
}
<div class="auth">
<button class="button" type="submit">Войти</button>
</div>
如何使矩形不出现在按钮之外?