๐ŸŒŠ Wave Button

MINBOKยท2021๋…„ 11์›” 21์ผ
12

Project

๋ชฉ๋ก ๋ณด๊ธฐ
1/5

HTML๊ณผ CSS๋ฅผ ์ด์šฉํ•ด์„œ ์ž”์ž”ํ•œ ๋ฌผ๊ฒฐ์ด ์ด๋Š” ๋ฒ„ํŠผ์„ ๋งŒ๋“ค์—ˆ๋‹ค.๐ŸŒŠ
๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด ๋ฌผ๊ฒฐ์ด ์ผ๋„๋ก ํ•˜๋ฉด ๋” ๋ฉ‹์žˆ์„ ๊ฒƒ ๊ฐ™๋‹ค.
๋‚˜์ค‘์— JS๋ฐฐ์šฐ๋ฉด ํ•œ๋ฒˆ ์‹œ๋„ํ•ด๋ด์•ผ์ง€๐Ÿ˜Ž

Codepen์—์„œ ๋ณธ ๋ฒ„ํŠผ์„ ์ฐธ๊ณ ํ•ด์„œ ๋งŒ๋“ค์—ˆ๋‹ค.
https://codepen.io/Wyper/pen/rNjrxrG

์ฝ”๋“œํŽœ ์ฝ”๋“œ๋ฅผ ๋ณด๋ฉด์„œ ์ดํ•ด๊ฐ€ ์•ˆ๋˜๋Š” ์ฝ”๋“œ๋“ค์„ ๊ณต์ฑ…์— ์ •๋ฆฌํ–ˆ๋‹ค.
์—ญ์‹œ ํƒ€์ž๋ณด๋‹ค๋Š” ์†์œผ๋กœ ์“ฐ๋Š”๊ฒŒ ํ›จ์”ฌ ํŽธํ•˜๋‹ค.
๊ทธ๋ž˜์„œ ์•„์ดํŒจ๋“œ๊ฐ€ ์ข€ ์‚ฌ๊ณ ์‹ถ๋„ค... ๊ทผ๋ฐ ๋„ˆ๋ฌด ๋น„์‹ธ๋‹ค.๐Ÿ˜ข

What I learned

1. :root

: ์›น ๋ฌธ์„œ๊ตฌ์กฐ์—์„œ ๊ฐ€์žฅ ์ƒ์œ„์š”์†Œ๋ฅผ ์„ ํƒํ•œ๋‹ค.
HTML์—์„œ์˜ root๋Š” ํ•ญ์ƒ html์ด๋‹ค.

/*root ๋‚ด๋ถ€์— ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•จ*/

:root {
    --maincolor: #86a8e7;
    --darkcolor: #7f7fd5;
    --brightcolor: #f7f7f7;
}

2. calc

: ์‹์˜ ๊ณ„์‚ฐ ๊ฒฐ๊ณผ๋ฅผ ์†์„ฑ๊ฐ’์œผ๋กœ ์‚ฌ์šฉํ•˜๊ฒŒ ํ•ด์ฃผ๋Š” ํ•จ,
์‚ฌ์น™์—ฐ์‚ฐ์ž ์‚ฌ์šฉ

:root {
  --Shift: 6px;
  --Blur: 15px;
}

box-shadow: calc(var(--Shift) * -1) 0 var(--Blur) rgba(255 255 255 / 1);

3. :focus-visible

: focus์™€๋Š” ๋‹ฌ๋ฆฌ ํ‚ค๋ณด๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํฌ์ปค์Šค ํ• ๋•Œ๋งŒ ์ ์šฉ๋Œ,
(for. ์Šคํฌ๋ฆฐ๋ฆฌ๋”)

4. filter

: ํ๋ฆผ, ์ƒ‰์ƒ ๋ณ€ํ˜• ๋“ฑ์˜ ๊ทธ๋ž˜ํ”ฝ ํšจ๊ณผ ์ ์šฉ

  • none : no effects (Default)

  • blur(px) : blur effect, larger value will create more blur.

  • brightness(%)

    • 0% : will make the img completely black
    • 100% (1) : is Default, original img
    • over 100% : will provide brighter results
  • contrast(%)

  • drop-shadow
    ( h-shadow(px), v-shadow(px), blur(px), spread(px), color )

    • required: h-shadow(px), v-shadow(px)
  • grayscale(%) : 0% ~ 100% (Default ~ completely gray)

  • hue-rotate(deg) : 0deg ~ 360deg (0 is default)

  • invert(%) : ์ƒ‰์ƒ๋ฐ˜์ „, 0% ~ 100%,
    Negative values are not allowed

  • opacity(%) : 0% ~ 100%(1),
    (completely transparent ~ Default, original img)

  • saturate(%) : 0% ~ over 100%

    • 0% : un-saturated
    • 100% : Default, original img
    • over 100% : super-saturated
  • sepia(%) : 0% ~ 100% (Default ~ completely sepia),
    Negative values are not allowed

  • url() : XML, SVG

  • intial : Inherits from parent

  • inherit : default value

โœจ์ฐธ๊ณ 
https://www.w3schools.com/cssref/playit.asp?filename=playcss_filter&preval=saturate(8)

What I make

โœจ Github: https://minbok-1998.github.io/Wave-button/
โœจ Codepen: https://codepen.io/minbok-1998/pen/PoKgoKW
โœจ Instagram: https://www.instagram.com/tv/CWgt7DsAd2L/?utm_source=ig_web_copy_link

Code

HTML

<!DOCTYPE html>
<html lang="ko">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Wave Button</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Sriracha&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="../reset.css">
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <div class="container">
        <button class="btn"></button>
        <div class="wave_wrap">
            <div class="wave"></div>
            <div class="wave"></div>
            <div class="wave"></div>
        </div>
    </div>
</body>
</html>

CSS

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --shadowShift: 6px;
    --shadowBlur: 15px;
    --circleColor: rgb(241, 243, 246);
}

body {
    position: relative;
    min-height: 100vh;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-image: linear-gradient(to right, #fafafa 0%, #d8d8d8 100%);
}

.wave {
    position: relative;
    width: 500px;
    height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.wave__btn {
    z-index: 100;
    width: 80px;
    height: 80px;
    border-radius: 20px;
    border: none;
    background-color: var(--circleColor);
    transform: rotate(45deg);
    transition: transform 0.2s ease-out;

    box-shadow: var(--shadowShift) 0 var(--shadowBlur) rgba(55 84 170 / 0.2),
        calc(var(--shadowShift) * -1) 0 var(--shadowBlur) rgba(255 255 255 / 1);

    /*     box-shadow: inset var(--shadowShift) 0 var(--shadowBlur) rgba(55 84 170 / 0.2),
var(--shadowShift) 0 var(--shadowBlur) rgba(55 84 170 / 0.2),
inset calc(var(--shadowShift) * -1) 0 var(--shadowBlur)
rgba(255 255 255 / 1),
calc(var(--shadowShift) * -1) 0 var(--shadowBlur) rgba(255 255 255 / 1); */
}

.wave__btn:hover {
    cursor: pointer;
    transform: rotate(45deg) scale(1.1);
}

.wave__btn::before {
    content: "CLICK";
    color: #31373f;
    font-weight: bold;
    font-size: 12px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: auto;
    transform: rotate(-45deg);
}

.wave__btn:focus {
    outline: none;
}

.wave__btn:focus-visible {
    border-color: #89aedf;
}

.wave__btn:active {
    opacity: 0.7;
    transform: rotate(45deg) scale(1);
}

.wave__container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.wave__circle {
    position: absolute;
    background-color: transparent;
    border: 10px solid var(--circleColor);
    border-radius: 50%;
    box-shadow: inset var(--shadowShift) var(--shadowShift) var(--shadowBlur) rgba(55 84 170 / 0.2),
        var(--shadowShift) var(--shadowShift) var(--shadowBlur) rgba(55 84 170 / 0.2),
        inset calc(var(--shadowShift) * -1) calc(var(--shadowShift) * -1) var(--shadowBlur) rgba(255 255 255 / 1),
        calc(var(--shadowShift) * -1) calc(var(--shadowShift) * -1) var(--shadowBlur) rgba(255 255 255 / 1);
    filter: blur(3px);

    animation-name: ripple;
    animation-duration: 3s;
    animation-timing-function: cubic-bezier(0, 0.2, 0.8, 1);
    animation-iteration-count: infinite;
}

.wave__container .wave__circle:nth-child(2) {
    animation-delay: -1s;
}

.wave__container .wave__circle:nth-child(3) {
    animation-delay: -2s;
}

@keyframes ripple {
    0% {
        top: 250px;
        left: 250px;
        width: 0;
        height: 0;
        opacity: 1;
    }

    100% {
        top: 0;
        left: 0;
        width: 500px;
        height: 500px;
        opacity: 0;
    }
}

4๊ฐœ์˜ ๋Œ“๊ธ€

comment-user-thumbnail
2021๋…„ 11์›” 22์ผ

ํ— ๋ฒ„ํŠผ ๋„ˆ๋ฌด ์˜ˆ๋ป์š”,, ๋‹ด์— ๊ผญ ๋”ฐ๋ผ ๋งŒ๋“ค์–ด๋ด์•ผ๊ฒ ์–ด์š”

1๊ฐœ์˜ ๋‹ต๊ธ€
comment-user-thumbnail
2021๋…„ 11์›” 29์ผ

์ตœ์ƒ๋‹จ์˜ codepen ๋งํฌ์— ์ด๋ชจํ‹ฐ์ฝ˜๊นŒ์ง€ ํฌํ•จ๋˜์—ˆ์Šต๋‹ˆ๋‹คใ… ใ… ใ… ใ… 
์ข‹์€ ์ž๋ฃŒ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค~~!

1๊ฐœ์˜ ๋‹ต๊ธ€