๐Ÿ”Ž CSS๊ฐ€ ๋ฌด์—‡์ผ๊นŒ?

์„œ๊ฐ€ํฌยท2022๋…„ 4์›” 5์ผ
2

CSS

๋ชฉ๋ก ๋ณด๊ธฐ
7/11
post-thumbnail

1. CSS๋ž€?


Cascading Style Sheets
Cascade : 'ํญํฌ๊ฐ€ ๋˜์–ด ๋–จ์–ด์ง€๋‹ค'์˜ ๋œป์„ ๊ฐ€์ง€๋Š” ๋‹จ์–ด
CSS ๋Š” ์šฐ์„ ์ˆœ์œ„๋ฅผ ๊ฐ€์ง€๊ณ  ์ ์šฉ์ด ๋˜๋Š”๋ฐ ์ด ์šฐ์„ ์ˆœ์œ„๊ฐ€ ์ ์šฉ๋˜๋Š” ๊ณผ์ •์ด ๋งˆ์น˜ ํญํฌ์ฒ˜๋Ÿผ ์œ„์—์„œ ์•„๋ž˜๋กœ ๋–จ์–ด์ง€๋Š” ๋ชจ์–‘์ด๋ผ cascade ๋ผ๋Š” ์ด๋ฆ„์„ ๊ฐ€์ง

CSS ์ ์šฉ์˜ ์šฐ์„ ์ˆœ์œ„

๋†’์€ ์ˆœ
1. ์‚ฌ์šฉ์ž ์ •์˜ ์Šคํƒ€์ผ
2. ํƒœ๊ทธ ์•ˆ์—์„œ ์ž‘์„ฑ๋˜๋Š” inline ์Šคํƒ€์ผ
3. head ํƒœ๊ทธ ์•ˆ์˜ ์Šคํƒ€์ผ
4. ์™ธ๋ถ€ ์Šคํƒ€์ผ ( ์™ธ๋ถ€์— ํŒŒ์ผ ๋‘๊ณ  link ๋กœ ์—ฐ๊ฒฐ )

1-1. CSS์˜ ์—ญํ• 

HTML์ด ์›น์˜ ๋ผˆ๋Œ€๋ผ๊ณ  ํ•œ๋‹ค๋ฉด CSS๋Š” HTML์„ ๊พธ๋ฉฐ์ฃผ๋Š” ๊ฐ€์ฃฝ, ํ”ผ๋ถ€

1-2. CSS3, CSS4 ๋Š” ์—†๋‹ค?!

CSS 2.1 ๊ฐœ๋ฐœ์ด ์™„๋ฃŒ๋˜๊ณ  CSSWG(CSS Working Group)๋Š” ๋” ์ด์ƒ CSS์˜ ๋ฒ„์ „์„ 3, 4์™€ ๊ฐ™์€ ๋ฉ”์ด์ € ์—…๋ฐ์ดํŠธ๋กœ ๊ฐ€์ ธ๊ฐ€์ง€ ์•Š๊ธฐ๋กœ ๊ฒฐ์ •.
์™œ????
1. CSS1์—์„œ CSS2๋กœ ์—…๋ฐ์ดํŠธ ๋˜๋Š”๋ฐ ์ˆ˜๋งŽ์€ ๊ธฐ๋Šฅ๋“ค์ด ์ถ”๊ฐ€๋˜์–ด์•ผ ํ–ˆ๊ณ 
2. ๊ฐ๊ฐ์˜ ๊ธฐ๋Šฅ๋“ค์ด ๊ฐœ๋ฐœ๋˜๋Š”๋ฐ ์žˆ์–ด ์˜๊ฒฌ์„ ๋ฐ›๊ณ  ๋™์˜๋ฅผ ๊ตฌํ•˜๋Š” ๊ธฐ๊ฐ„๋„ ๋Š˜์–ด๋‚จ์— ๋”ฐ๋ผ
3. ์ด๋ฏธ ์™„๋ฃŒ๋œ ๊ธฐ๋Šฅ์€ ๋ฐœํ‘œํ•˜์ง€ ๋ชปํ•˜๊ณ  ์ง€์ฒด๋˜๋Š” ์‹œ๊ฐ„์ด ๋ฐœ์ƒํ–ˆ๊ณ 
4. ๊ฒฐ๊ตญ CSS2 ์ „์ฒด๋ฅผ ๊ฐœ๋ฐœ์™„๋ฃŒ ํ•˜๊ธฐ๊นŒ์ง€ 9๋…„์ด๋ผ๋Š” ์‹œ๊ฐ„์ด ํ•„์š”ํ–ˆ๊ธฐ ๋•Œ๋ฌธ.
์–ด์จŒ๋“  ์ด์ œ๋Š” ๊ธฐ๋Šฅ๋“ค์„ ์ž‘์€ ๋‹จ์œ„๋กœ ๋‚˜๋ˆ„์–ด ๊ฐœ๋ฐœํ•˜๊ณ , ์™„๋ฃŒ๋œ ๊ฒƒ ๋จผ์ € ์—…๋ฐ์ดํŠธ ํ•˜๊ธฐ๋กœ ๋ฐฉํ–ฅ์„ ๋ฐ”๊ฟˆ. ์ด๋•Œ CSS ๊ธฐ๋Šฅ์˜ ๋‹จ์œ„๋ฅผ ๋ชจ๋“ˆ(module) ์ด๋ผ๊ณ  ํ‘œํ˜„.

๋”์ด์ƒ level ์ด ์•„๋‹Œ Module Level 3 ๋กœ ํ‘œํ˜„
์•ž์œผ๋กœ CSS์˜ ๋ช…์นญ์€ CSS3, CSS4๊ฐ€ ์•„๋‹Œ CSS ๋ผ๊ณ  ๋ถ€๋ฅด์ž ใ…Žใ…Ž

1-3. CSS ์˜ ๊ธฐ๋ณธ ๊ตฌ์กฐ

  • selector : ์„ ํƒ์ž , ์Šคํƒ€์ผ์„ ์ ์šฉํ•˜๊ณ ์ž ํ•˜๋Š” HTML ์š”์†Œ๋ฅผ ์„ ํƒ
  • property : ์†์„ฑ, ์Šคํƒ€์ผ ์†์„ฑ ์ด๋ฆ„
  • value : ๊ฐ’, ์†์„ฑ์— ๋Œ€์‘๋˜๋Š” ๊ฐ’

2. CSS ์ ์šฉํ•˜๊ธฐ


2-1. ์ธ๋ผ์ธ ๋ฐฉ์‹

Html ํƒœ๊ทธ ๋‚ด๋ถ€์— ์Šคํƒ€์ผ๋งํ•˜๋Š” ๋ฐฉ์‹

<body>
	<h1 style='color:red; background-color:yellow;'>Hello world</h1>
</body>

2-2. ๋‚ด๋ถ€ ์Šคํƒ€์ผ ์‹œํŠธ

Html <head> ๋‚ด๋ถ€์— <style> ํƒœ๊ทธ ๋งŒ๋“ฆ

<!DOCTYPE html>
<html lang="ko">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>Document</title>
	<style>
		h1 {
				color:red;
				background-color:yellow;
		}
	</style>
</head>
<body>
	<h1>Hello world</h1>
</body>
</html>

2-3. ์™ธ๋ถ€ ์Šคํƒ€์ผ ์‹œํŠธ

css ํŒŒ์ผ์„ ๋”ฐ๋กœ ๋งŒ๋“ค์–ด <link>๋กœ ์—ฐ๊ฒฐ

<head>
	<link rel="stylesheet" href="css/foo.css">
</head>

2-4. ๋‹ค์ค‘ ์Šคํƒ€์ผ ์‹œํŠธ

CSS ํŒŒ์ผ ์•ˆ์— CSS ํŒŒ์ผ import

 @import "foo.css";

at-rule

@๊ฐ€ ๋ถ™๋Š” ๋ฌธ๋ฒ•. import๋งŒ ์žˆ๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๊ณ  ์•„๋ž˜์ฒ˜๋Ÿผ ๋‹ค์–‘ํ•œ at-rule์ด ์žˆ์Œ.

  • @charset : ์Šคํƒ€์ผ์‹œํŠธ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๋ฌธ์ž ์ธ์ฝ”๋”ฉ์„ ์ง€์ •. ๋ฌธ์„œ์—์„œ ๊ฐ€์žฅ ๋จผ์ € ์„ ์–ธ.
  • @import : ๋‹ค๋ฅธ ์Šคํƒ€์ผ ์‹œํŠธ์—์„œ ์Šคํƒ€์ผ ๊ทœ์น™์„ ๊ฐ€์ ธ์˜ด. @charset ๋ฐ”๋กœ ๋‹ค์Œ์— ์„ ์–ธ๋˜์–ด์•ผํ•จ.
  • @font-face : ๋””๋ฐ”์ด์Šค์— ์—†๋Š” ํฐํŠธ๋ฅผ ๋‹ค์šด๋ฐ›์•„ ์ ์šฉํ•  ๋•Œ ์‚ฌ์šฉ.
  • @keyframes : ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋งŒ๋“ค ๋•Œ ์‚ฌ์šฉ.
  • @media : ์‚ฌ์šฉ์ž ๋””๋ฐ”์ด์Šค์— ๋”ฐ๋ฅธ ์Šคํƒ€์ผ์„ ๋ถ„๊ธฐ ์ฒ˜๋ฆฌํ•˜๊ณ ์ž ํ•  ๋•Œ ์‚ฌ์šฉ.
  • @supports : ํŠน์ • CSS ์†์„ฑ์„ ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์ง€์›ํ•˜๋Š”์ง€ ํ™•์ธํ•˜๊ณ  ์Šคํƒ€์ผ์„ ์„ ์–ธํ•˜๊ณ ์ž ํ•  ๋•Œ ์‚ฌ์šฉ.

3. Reset CSS

๋ฌธ์ œ์˜ ์‹œ์ž‘.
์ˆ˜ ๋งŽ์€ ๋ธŒ๋ผ์šฐ์ €์˜ ๊ฐ์ž ๋‹ค๋ฅธ ๊ธฐ๋ณธ ์Šคํƒ€์ผ

3-1. ์—๋ฆญ ๋งˆ์ด์–ด์˜ reset CSS

๋งค์šฐ ์˜ค๋ž˜์ „๋ถ€ํ„ฐ ๋„๋ฆฌ ์‚ฌ์šฉ๋œ ๋ฐฉ๋ฒ•.
๋ธŒ๋ผ์šฐ์ €์˜ ๋ชจ๋“  ๊ธฐ๋ณธ์ ์ธ ์Šคํƒ€์ผ ์†์„ฑ๋“ค์„ ์™„์ „ํžˆ ์ดˆ๊ธฐํ™” ์‹œ์ผœ์„œ ๋ชจ๋“  ์Šคํƒ€์ผ์„ ์ฒ˜์Œ๋ถ€ํ„ฐ ๋งŒ๋“ค๋„๋ก ํ•จ.
reset.css ์ฝ”๋“œ๋ฅผ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ๊ณ , ์—ฌ๊ธฐ์— ํ”„๋กœ์ ํŠธ๋งŒ์„ ์œ„ํ•œ ์ปค์Šคํ…€ ์Šคํƒ€์ผ์„ ์ถ”๊ฐ€ํ•ด์„œ ์‚ฌ์šฉํ•˜๊ธฐ๋„ ํ•จ.

<!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>reset</title>
    <style>
        /* reset.css */
        html, body, div, span, applet, object, iframe,
        h1, h2, h3, h4, h5, h6, p, blockquote, pre,
        a, abbr, acronym, address, big, cite, code,
        del, dfn, em, img, ins, kbd, q, s, samp,
        small, strike, strong, sub, sup, tt, var,
        b, u, i, center,
        dl, dt, dd, ol, ul, li,
        fieldset, form, label, legend,
        table, caption, tbody, tfoot, thead, tr, th, td,
        article, aside, canvas, details, embed, 
        figure, figcaption, footer, header, hgroup, 
        menu, nav, output, ruby, section, summary,
        time, mark, audio, video {
            margin: 0;
            padding: 0;
            border: 0;
            font-size: 100%;
            font: inherit;
            vertical-align: baseline;
        }
        /* HTML5 display-role reset for older browsers */
        article, aside, details, figcaption, figure, 
        footer, header, hgroup, menu, nav, section {
            display: block;
        }
        body {
            line-height: 1;
        }
        ol, ul {
            list-style: none;
        }
        blockquote, q {
            quotes: none;
        }
        blockquote:before, blockquote:after,
        q:before, q:after {
            content: '';
            content: none;
        }
        table {
            border-collapse: collapse;
            border-spacing: 0;
        }
        body{
            font-family:'ํšŒ์‚ฌ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๊ธฐ๋ณธ ํฐํŠธ', '๋ง‘์€ ๊ณ ๋”•','Malgun Gothic', AppleGothic,sans-serif;
            font-size: 16px;
            font-weight: 400;
            /* ์•„์ดํฐ์— reset font๊ฐ€ ์„ค์ •์ด ์•ˆ๋˜๋Š” ๊ฒฝ์šฐ๊ธฐ ์žˆ์–ด ์„ค์ •ํ•ด์ฃผ์–ด์•ผ ํ•จ  */
            -webkit-text-size-adjust:none;
        }
        p,div,h1,h2,h3,h4,h5,h6,ul,ol,li,dl,dt,dd,table,th,td,form,fieldset,legend,input,textarea,select,button,code,label,em,span,strong {
            /* ๋‹จ์–ด ๋‹จ์œ„๋กœ ๋–จ์–ด์ ธ ๋‚ด๋ฆฌ๊ฒŒ๋” */
            word-break:keep-all;
        }
        /* ์ต์Šคํ”Œ๋กœ๋Ÿฌ ํ•˜์œ„ ๋ฒ„์ „์—์„œ a > img์ผ ๊ฒฝ์šฐ ๋ณด๋”๊ฐ€ ์ƒ๊น€ */
        img,fieldset{border:0}
        legend{
            position:absolute;
            left:-9999px;
            font-size:0;
            overflow:hidden;
        }

        input,select,textarea{
            /* ๋ชจ๋ฐ”์ผ ๊ธฐ๋ณธ ์ œ๊ณต ์Šคํƒ€์ผ ์ œ๊ฑฐ */
            -webkit-appearance:none;
            -moz-appearance:none;
        }
        /* IE ์…€๋ ‰๋ฐ•์Šค ๊ธฐ๋ณธ ํ™”์‚ดํ‘œ ์ œ๊ฑฐ */
        select::-ms-expand{display:none;}
        /* ํฌ๊ธฐ ์กฐ์ ˆํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋ธ”๋ก ์š”์†Œ๋กœ ๋ฐ”๊ฟˆ */ 
        a {
        	display:block;
        }
        table, th, tr, td {
        	display:block;
        }
        img {
        	display: block;
            width: 100%; ๋ถ€๋ชจํ•œํ…Œ 100%
        }
    </style>
</head>
<body>
    <h1>hello world</h1>
    <h2>hello world</h2>
    <h3>hello world</h3>
    <h4>hello world</h4>
    <h5>hello world</h5>
    <h6>hello world</h6>
    <p>hello world</p>
</body>
</html>

3-2. normalize.css

๋…ธ๋ฉ€๋ผ์ด์ฆˆ๋Š” ๋ธŒ๋ผ์šฐ์ €์˜ ๊ธฐ๋ณธ์ ์ธ ์Šคํƒ€์ผ ์†์„ฑ๋“ค์„ ๋ชจ๋‘ ์ œ๊ฑฐํ•˜์ง€ ์•Š์Œ.
๋ธŒ๋ผ์šฐ์ € ์Šคํƒ€์ผ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•˜๊ณ  ๊ฑฐ๊ธฐ์— ์ถ”๊ฐ€์ ์ธ ์Šคํƒ€์ผ์„ ๋ง๋ถ™์—ฌ ์–ด๋–ค ๋ธŒ๋ผ์šฐ์ €์—์„œ๋“  ๋น„์Šทํ•˜๊ฒŒ ๋ณด์ด๋„๋ก ํ†ต์ผ.
์ฆ‰, ์•ž์„œ ๋ฐฐ์šด reset.css ๊ฐ€ ๊ธฐ์กด ์Šคํƒ€์ผ์„ ๋ชจ๋‘ ์ œ๊ฑฐํ•˜๋Š” ์ ๊ทน์ ์ธ ๋ฐฉ๋ฒ•์ด๋ผ๋ฉด, normalize๋Š” ๋ธŒ๋ผ์šฐ์ € ๊ณ ์œ ์˜ ์Šคํƒ€์ผ์„ ์กด์ค‘ํ•˜๋ฉด์„œ ๊ฑฐ๊ธฐ์— ์Šคํƒ€์ผ์„ ์ฒจ๊ฐ€ํ•˜๋Š”, ์ข€ ๋” ๋ถ€๋“œ๋Ÿฌ์šด ๋ฐฉ๋ฒ•์ด๋‹ค!!

3-2. CSS Remedy

๋งŒ์•ฝ CSSWG์—์„œ CSS๋ฅผ ์ œ์ž‘ํ•˜๋Š” ์‚ฌ๋žŒ๋“ค์˜ ์ž…์žฅ์ด๋ผ๋ฉด, ์–ด๋–ค์‹์œผ๋กœ ๋ธŒ๋ผ์šฐ์ €์—๊ฒŒ ๊ธฐ๋ณธ ์Šคํƒ€์ผ์„ ์ฃผ๊ฒŒ ๋ ๊นŒ ๋ผ๋Š” ์ƒ๊ฐ์—์„œ ์ถœ๋ฐœํ•œ ์ฐจ์„ธ๋Œ€ CSS reset ํ”„๋กœ์ ํŠธ
โ€œSets CSS properties or values to what they would be if the CSSWG were creating the CSS today, from scratch, and didnโ€™t have to worry about backwards compatibility.โ€

ํ•˜์œ„ ๋ธŒ๋ผ์šฐ์ € ํ˜ธํ™˜ ๊ฑฑ์ •์—†์ด CSS๊ฐ€ ๋ธŒ๋ผ์šฐ์ €์—์„œ ํšจ์œจ์ ์œผ๋กœ ์ž‘๋™ํ•˜๋„๋ก ํ•˜๋Š” ๊ฒƒ์ด ๋ชฉํ‘œ
ํ˜„์žฌ ์ง„ํ–‰ ์ค‘ :)

body font-size:16px -> ์›๋ž˜ 16px์ด์ง€๋งŒ ์ ์šฉ ์•ˆ๋œ ์•„์ดํฐ ๋•Œ๋ฌธ์— ์จ์คŒ

๐Ÿ™†๐Ÿปโ€โ™€๏ธํšŒ๊ณ 


CSS ์‹œ์ž‘!!!๊บ†!!!!!!!!ํ™”์ดํŒ…!!!!!!!!!!!!
์ฃผ์„ ๋‹ฌ์•„๋†“๋Š” ๊ฒƒ ์Šต๊ด€ํ™” ํ•˜๊ธฐ

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

comment-user-thumbnail
2022๋…„ 4์›” 6์ผ

CSS์˜ ๋ช…์นญ์€ CSS3, CSS4๊ฐ€ ์•„๋‹Œ CSS !!!
๋จธ๋ฆฟ์†์— ๊ฐ์ธํ•˜๊ณ  ๊ฐ‘๋‹ˆ๋‹ค!!!!๐Ÿ’ก๐Ÿ’ก

๋‹ต๊ธ€ ๋‹ฌ๊ธฐ
comment-user-thumbnail
2022๋…„ 4์›” 7์ผ

CSS ๋ณต์Šต ๊ฐ™์ด ํ›„๋‹ค๋‹ฅ ํ•ด๋ด…๋‹ˆ๋‹ค!

๋‹ต๊ธ€ ๋‹ฌ๊ธฐ