๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
JavaScript/Vanilla JS

[๋ฐ”๋‹๋ผJS๋กœ ๊ทธ๋ฆผํŒ ๋งŒ๋“ค๊ธฐ] Styles part One

by ์ฝ”๋”ฉํ•˜๋Š” ๋ถ•์–ด 2021. 4. 23.
๋ฐ˜์‘ํ˜•

[์ถœ์ฒ˜-์œ ํŠœ๋ธŒ ๋…ธ๋งˆ๋“œ ์ฝ”๋” Nomad Coders]

https://youtu.be/V4yUrRjAiDQ

 

CSS๋ฅผ ์†๋ณผ๊ฑฐ์ž„...

 

์šฐ์„  ๋ฐฐ๊ฒฝ ์ƒ‰์„ ์ง€์ •ํ•˜๊ณ 

 

 

๊ตฌ๊ธ€์— 'reset css'๋ฅผ ๊ฒ€์ƒ‰ํ•œ ํ›„ ๋ฐ‘์ค„ ์นœ ์‚ฌ์ดํŠธ์— ๋“ค์–ด๊ฐ„๋‹ค.

 

 

์ด๋ ‡๊ฒŒ ๋ญ”๊ฐ€๊ฐ€ ๋œฐ๊ฒƒ์ด๋‹ค... ๊ณ ๋Œ€๋กœ ๋ณต์‚ฌํ•œ๋‹ค.

 

 

reset.css๋ฅผ ์ƒˆ๋กœ ์ƒ์„ฑํ•˜๊ณ  ์œ„์— ๋ณต์‚ฌํ•œ ์ฝ”๋“œ๋ฅผ ๋ถ™์—ฌ๋„ฃ๊ธฐํ•œ๋‹ค.

 

 

styles.css๋„ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•œ๋‹ค.

 

 

์ด์ œ ์บ”๋ฒ„์Šค๋ฅผ ๋งŒ๋“ ๋‹ค.

index.html์—” id๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  style์—” class๋ฅผ ์‚ฌ์šฉํ•  ๊ฒƒ์ž„

 

 

 

style.css๋ฅผ ์ข€๋” ์ˆ˜์ •ํ•œ๋‹ค.

@import "reset.css";

body {
    background-color: #f6f9fc;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 50px;
}

.canvas {
    width: 700px;
    height: 700px;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
}

 

 

์ด์ œ control์„ ๋งŒ๋“ ๋‹ค.

<!DOCTYPE html>
<html lang="en">
<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" />
    <link rel="stylesheet" href="styles.css" />
    <title>PaintJS</title>
</head>
<body>
    <canvas id="jsCanvas" class="canvas"></canvas>
    <div class="controls">
        <div class="controls__colors" id="jsColors">
            <div class="controls__color"></div>
            <div class="controls__color"></div>
            <div class="controls__color"></div>
            <div class="controls__color"></div>
            <div class="controls__color"></div>
            <div class="controls__color"></div>
            <div class="controls__color"></div>
            <div class="controls__color"></div>
            <div class="controls__color"></div>
        </div>
    </div>
    <script src="app.js"></script>
</body>
</html>

 

 

์ด์ œ ์ € controls__colorํ•œํ…Œ ๊ฐ๊ฐ ๋ฐฐ๊ฒฝ์ƒ‰์„ ๋„ฃ์–ด์ค€๋‹ค.

<!DOCTYPE html>
<html lang="en">
<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" />
    <link rel="stylesheet" href="styles.css" />
    <title>PaintJS</title>
</head>
<body>
    <canvas id="jsCanvas" class="canvas"></canvas>
    <div class="controls">
        <div class="controls__colors" id="jsColors">
            <div class="controls__color" style="background-color: black"></div>
            <div class="controls__color" style="background-color: white"></div>
            <div class="controls__color" style="background-color: #ff3b3c"></div>
            <div class="controls__color" style="background-color: #ff9500"></div>
            <div class="controls__color" style="background-color: #ffcc00"></div>
            <div class="controls__color" style="background-color: #4cd963"></div>
            <div class="controls__color" style="background-color: #5ac8fa"></div>
            <div class="controls__color" style="background-color: #0579ff"></div>
            <div class="controls__color" style="background-color: #5856d6"></div>
        </div>
    </div>
    <script src="app.js"></script>
</body>
</html>

 

 

controls์— ์•ฝ๊ฐ„์˜ ์Šคํƒ€์ผ์„ ์ค€๋‹ค.

.controls {
    margin-top: 80px;
}

.controls .controls__colors {
    display: flex;
}

.controls__colors .controls__color {
    width: 50px;
    height: 50px;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
}

์ ์šฉ์ด ์ž˜ ๋˜์—ˆ๋‹ค.

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€