https://codepen.io/jh3y/pen/jjRezM
HTML :
<div class="container">
<button role="button" tabindex="0" style="--buttonColor: #0088FF;">Boo!<span></span><span></span><span></span><span></span>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
</button>
<button role="button" tabindex="0" style="--buttonColor: #FFAA00;">Boo!<span></span><span></span><span></span><span></span>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
</button>
<button role="button" tabindex="0" style="--buttonColor: #FF7700;">Boo!<span></span><span></span><span></span><span></span>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
</button>
<button role="button" tabindex="0" style="--buttonColor: #FF0033;">Boo!<span></span><span></span><span></span><span></span>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
</button>
<button role="button" tabindex="0" style="--buttonColor: #9911AA;">Boo!<span></span><span></span><span></span><span></span>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
</button>
<button role="button" tabindex="0" style="--buttonColor: #AADD22;">Boo!<span></span><span></span><span></span><span></span>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
<div aria-hidden="true">Boo!</div>
</button>
</div>
CSS :
*,
*:after,
*:before {
box-sizing: border-box;
}
:root {
--bg: #fafafa;
}
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background: var(--bg);
color: var(--bg);
}
.container {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 20px;
}
button {
--borderWidth: 5;
--boxShadowDepth: 8;
--buttonColor: #f00;
--fontSize: 3;
--horizontalPadding: 16;
--verticalPadding: 8;
background: transparent;
border: calc(var(--borderWidth) * 1px) solid var(--buttonColor);
box-shadow: calc(var(--boxShadowDepth) * 1px) calc(var(--boxShadowDepth) * 1px) 0 #888;
color: var(--buttonColor);
cursor: pointer;
font-size: calc(var(--fontSize) * 1rem);
font-weight: bold;
outline: transparent;
padding: calc(var(--verticalPadding) * 1px) calc(var(--horizontalPadding) * 1px);
position: relative;
transition: box-shadow 0.15s ease;
}
button:hover {
box-shadow: calc(var(--boxShadowDepth) / 2 * 1px) calc(var(--boxShadowDepth) / 2 * 1px) 0 #888;
}
button:active {
box-shadow: 0 0 0 #888;
}
button span {
-webkit-clip-path: var(--clip);
bottom: calc(var(--borderWidth) * -1px);
clip-path: var(--clip);
left: calc(var(--borderWidth) * -1px);
opacity: 0.25;
position: absolute;
right: calc(var(--borderWidth) * -1px);
top: calc(var(--borderWidth) * -1px);
z-index: 1;
}
button span:nth-of-type(1):hover,
button span:nth-of-type(2):hover,
button span:nth-of-type(3):hover,
button span:nth-of-type(4):hover {
--clip: polygon(0 0, 100% 0, 100% 100%, 0 100%);
z-index: 2;
}
button span:nth-of-type(1):hover ~ div:nth-of-type(1),
button span:nth-of-type(2):hover ~ div:nth-of-type(2),
button span:nth-of-type(3):hover ~ div:nth-of-type(3),
button span:nth-of-type(4):hover ~ div:nth-of-type(4) {
--clip: inset(0 0 0 0);
}
button span:nth-of-type(1) {
--clip: polygon(0 0, 100% 0, 50% 50%, 50% 50%);
}
button span:nth-of-type(2) {
--clip: polygon(100% 0, 100% 100%, 50% 50%);
}
button span:nth-of-type(3) {
--clip: polygon(0 100%, 100% 100%, 50% 50%);
}
button span:nth-of-type(4) {
--clip: polygon(0 0, 0 100%, 50% 50%);
}
button div {
-webkit-clip-path: var(--clip);
background: var(--buttonColor);
border: calc(var(--borderWidth) * 1px) solid var(--buttonColor);
bottom: calc(var(--borderWidth) * -1px);
clip-path: var(--clip);
color: var(--bg, #fafafa);
left: calc(var(--borderWidth) * -1px);
padding: calc(var(--verticalPadding) * 1px) calc(var(--horizontalPadding) * 1px);
position: absolute;
right: calc(var(--borderWidth) * -1px);
top: calc(var(--borderWidth) * -1px);
transition: -webkit-clip-path 0.25s ease;
transition: clip-path 0.25s ease;
transition: clip-path 0.25s ease, -webkit-clip-path 0.25s ease;
}
button div:nth-of-type(1) {
--clip: inset(0 0 100% 0);
}
button div:nth-of-type(2) {
--clip: inset(0 0 0 100%);
}
button div:nth-of-type(3) {
--clip: inset(100% 0 0 0);
}
button div:nth-of-type(4) {
--clip: inset(0 100% 0 0);
}
등록된 댓글이 없습니다.