<!DOCTYPE html>
<html>
<head>
<title>CSS Modern Button</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<!-- i태그는 버튼위의 바. -->
<a href="#" style="--clr:#1e9bff"><span>눌러라!</span><i></i></a>
<a href="#" style="--clr:#6eff3e"><span>만져라!</span><i></i></a>
<a href="#" style="--clr:#ff1867"><span>벗겨라!</span><i></i></a>
</body>
</html>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap');
*
{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
}
body
{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: rgb(10, 26, 29);
flex-direction: column;
gap: 40px;
}
a
{
position: relative;
background: white;
color: rgb(255, 255, 255);
text-decoration: none;
text-transform: uppercase;
font-size: 1.5em;
letter-spacing: 00.1em;
font-weight: 400;
padding: 10px 30px;
transition: 0.5s;
}
a:hover
{
background: var(--clr);
color: var(--clr);
/* 좌우로 흩어지는 효과. */
letter-spacing: 00.35em;
/* html에서 색깔 변수를 지정해서 버튼의 그림자 색을 결정. */
box-shadow: 0 0 35px var(--clr);
}
a::before
{
content: '';
position: absolute;
inset: 2px;
background: rgb(9, 16, 28);
}
span
{
position: relative;
z-index: 1;
}
i
{
position: absolute;
inset: 0;
display: block;
}
i::before
{
content: '';
position: absolute;
top: 0;
left: 80%;
width: 10px;
height: 4px;
background: rgb(31, 19, 19);
/* skew로 수평방향 기울이기. */
transform: translateX(-50%) skewX(325deg);
transition: 00.5s;
}
a:hover i::before
{
width: 20px;
left: 20%;
}
i::after
{
content: '';
position: absolute;
bottom: 0;
left: 20%;
width: 10px;
height: 4px;
background: rgb(31, 19, 19);
transform: translateX(-50%) skew(325deg);
transition: 00.5s;
}
a:hover i::after
{
width: 20px;
/* left를 20에서 80%로 전환함으로 호버시 바가 좌우로 움직임. */
left: 80%;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.