CSS下的Button(四)
示例
代码
html
<button class="my-btn4"> Button
<span></span>
</button>
css
.my-btn4 {
border: none;
display: block;
position: relative;
padding: 0.7em 2.4em;
font-size: 18px;
background: transparent;
cursor: pointer;
user-select: none;
overflow: hidden;
color: royalblue;
z-index: 1;
font-family: inherit;
font-weight: 500;
}
.my-btn4 span {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: transparent;
z-index: -1;
border: 4px solid royalblue;
}
.my-btn4 span::before {
content: "";
display: block;
position: absolute;
width: 8%;
height: 500%;
/* 自己的背景主题色 */
background: var(--vp-c-bg);
top: 50%;
left: 50%;
transform: translate(-50%, -50%) rotate(-60deg);
transition: all 0.3s;
}
.my-btn4:hover span::before {
transform: translate(-50%, -50%) rotate(-90deg);
width: 100%;
background: royalblue;
}
.my-btn4:hover {
color: white;
}
.my-btn4:active span::before {
background: #2751cd;
}