<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Botão com efeito hover</title>
</head>
<body>
<button class="btn">Desafio 30 dias de CSS</button>
</body>
</html>
HTML
格式化
支持Emmet,输入 p 后按 Tab键试试吧!
<head> ... </head>
<body>
</body>
CSS
格式化
body
{
margin: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
font-family: sans-serif;
}
.btn
{
border: 2px solid rgb(0, 165, 124);
background: none;
color: rgb(0, 165, 124);
padding: 20px 40px;
font-size: 25px;
text-transform: uppercase;
cursor: pointer;
transition: all 0.5s;
position: relative;
overflow: hidden;
}
.btn:hover
{
color: white;
}
.btn::before
{
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgb(0, 165, 124);
z-index: -1;
border-radius: 0 0 50% 50%;
height: 0%;
transition: all 0.5s;
}
.btn:hover::before{
height: 190%;
}
JS
格式化