5 ๋ถ„ ์†Œ์š”

๐Ÿ“š CSS


๐Ÿ“š Font & Text

CSS Font

CSS Font ๊ด€๋ จ ์†์„ฑ์€ text์˜ ๊ธ€๊ผด, ๊ตต๊ธฐ, ํฌ๊ธฐ, ์Šคํƒ€์ผ๋“ฑ์„ ์ง€์ •ํ•œ๋‹ค.

font-family

  • ๊ธ€๊ผด ์ง€์ •
  • ์‚ฌ์šฉ๋ฒ•์€ โ€œ E { font-family: ๊ธ€๊ผด์ด๋ฆ„, ๊ธ€๊ผด์ด๋ฆ„, โ€ฆ }โ€ ์ด๋‹ค.
  • generic font๋ช…์„ ๋’ค์— ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์ด ์ผ๋ฐ˜์ ์ด๋‹ค.
<style type="text/css">
#serif { font-family : serif; }
</style>
</head>
<body>
    <p id="serif"> ๊ธ€์ž์ฒด๊ฐ€ serif์ด๋‹ค. </p>
</body>

font-size

  • ๊ธ€์ž ํฌ๊ธฐ ์ง€์ •
  • ์‚ฌ์šฉ๋ฒ• โ€œ E { font-size: ์†์„ฑ ๊ฐ’ } โ€œ ์ด๋‹ค.
  • ์ ˆ๋Œ€ ์‚ฌ์ด์ฆˆ ์†์„ฑ ๊ฐ’์€ xx-small, x-small, small, medium, large, x-large, xx-large๊ฐ€ ์žˆ๋‹ค.
  • ์ƒ๋Œ€ ์‚ฌ์ด์ฆˆ ์†์„ฑ ๊ฐ’์€ larger, smaller์ด ์žˆ๋‹ค.
  • ๊ทธ ์™ธ px, cm, % ( ๋ถ€๋ชจ ์—˜๋ฆฌ๋จผํŠธ์™€์˜ ๋น„์œจ ) ๋‹จ์œ„๋„ ์‚ฌ์šฉ ๊ฐ€๋Šฅ
<style type="text/css">
#h1 { font-size : 150%; }
#h2 { font-size : 100%; }
#p { font-size : 10px; }
</style>
</head>
<body>
    <h1 id="h1"> h1 ๊ธ€์ž ์‚ฌ์ด์ฆˆ ์ž…๋‹ˆ๋‹ค. </h1>
    <h2 id="h2"> h2 ๊ธ€์ž ์‚ฌ์ด์ฆˆ ์ž…๋‹ˆ๋‹ค. </h2>
    <p id="p"> p ๊ธ€์ž ์‚ฌ์ด์ฆˆ ์ž…๋‹ˆ๋‹ค. </p>
</body>

font-style

  • ๊ธ€์ž ์Šคํƒ€์ผ ์ง€์ •
  • ์‚ฌ์šฉ๋ฒ• โ€œ E { font-style: normal / italic / oblique } โ€œ ์ด๋‹ค.
  • ์†์„ฑ๊ฐ’์€ normal, italic, oblique ๊ฐ€ ์žˆ๊ณ  ๊ธฐ๋ณธ๊ฐ’์€ normal์ด๋‹ค.
  • italic, oblique ๋‘˜๋‹ค ๊ธฐ์šธ์ž„์ธ๋ฐ italic์€ ๋””์ž์ด๋„ˆ์— ์˜ํ•ด ๋””์ž์ธ๋œ ํŠน์ˆ˜ํ•œ ๊ธ€๊ผด์ด๊ณ  oblique๋Š” ์ผ๋ฐ˜ ๊ธ€์ž๋ฅผ 8~12eh ์ •๋„ ๊ธฐ์šธ์—ฌ์„œ ํ‘œ์‹œํ•œ ๊ฒƒ์ด๋‹ค.
<style type="text/css">
#normal { font-style : normal; }
#italic { font-style : italic; }
#oblique { font-style : oblique; }
</style>
</head>
<body>
    <p id="normal"> normal ๊ธ€์ž์ž…๋‹ˆ๋‹ค. </p>
    <p id="italic"> italic ๊ธ€์ž์ž…๋‹ˆ๋‹ค. </p>
    <p id="oblique"> oblique ๊ธ€์ž์ž…๋‹ˆ๋‹ค. </p>
</body>

font-variant

<style type="text/css">
#variant { font-variant : small-caps; }
</style>
</head>
<body>
    <p id="variant"> font-variant ์ ์šฉ.</p>
</body>

font-weight

  • ๊ธ€์ž ๊ตต๊ธฐ ์ง€์ •
  • ์‚ฌ์šฉ๋ฒ• โ€œ E { font-weight: normal / bold / bolder / lighter }โ€ ์ด๋‹ค.
  • ์ดˆ๊ธฐ๊ฐ’์€ normal์ด๋ฉฐ, 100~900๊นŒ์ง€ ์ˆซ์ž๊ฐ’์œผ๋กœ ์‚ฌ์šฉ๊ฐ€๋Šฅ ( normal : 400 , bold : 700 )
<style type="text/css">
#weight1 { font-weight : bold; }
#weight2 { font-weight : 500; }
#weight3 { font-weight : lighter; }
</style>
</head>
<body>
    <p id="weight1"> font-weight bold.</p>
    <p id="weight2"> font-weight 500.</p>
    <p id="weight3"> font-weight lighter.</p>
</body>

font

<style type="text/css">
#target { font: italic small-caps bold 13px/1.7em Arial; }
</style>
</head>
<body>
    <p id="target"> full options์ด ์ ์šฉ๋œ ๋ฌธ์žฅ์ž…๋‹ˆ๋‹ค. </p>
</body>

CSS Text

CSS Text ๊ด€๋ จ ์†์„ฑ์€ ๊ธ€์ž, ๊ณต๊ฐ„, ๋ฌธ๋‹จ๋“ค์ด ๋ณด์—ฌ์ง€๋Š” ์†์„ฑ์„ ์ •์˜ํ•œ๋‹ค.

text-align

  • text ์ •๋ ฌ ๋ฐฉ์‹ ์ง€์ •
  • ์‚ฌ์šฉ๋ฒ•์€ โ€œ E { text-align: left / right / center / justify } โ€œ ์ด๋‹ค.
  • justify๋Š” ๊ฐ ๋ผ์ธ์˜ ๋„ˆ๋น„๊ฐ€ ๋ชจ๋‘ ๋™์ผํ•˜๋„๋ก ๊ฐ„๊ฒฉ์„ ๋Š˜๋ฆฐ๋‹ค.
<style type = "text/css">
    body { width : 300px; }
    div { text-align : center; }
    </style>
    </head>
    <body>
        <div>
            div๋ถ€๋ถ„์˜ ํ…์ŠคํŠธ๋ฅผ ๋ชจ๋‘ ์ค‘์•™ ์ •๋ ฌ ์‹œํ‚จ๋‹ค.
        </div>
    </body>

text-decoration

  • text ์žฅ์‹ ์ง€์ •
  • ์‚ฌ์šฉ๋ฒ•์€ โ€œ E { text-decoration: none / underline / overline / line-through / blink } โ€œ ์ด๋‹ค.
  • underline์€ ๋ฐ‘์ค„์„ ์ƒ์„ฑ ํ•œ๋‹ค.
  • overline์€ text ์œ„์— ์ค„์„ ์ƒ์„ฑํ•œ๋‹ค.
  • line-through๋Š” text ์‚ฌ์ด๋กœ ๋ผ์ธ์„ ์ƒ์„ฑ ํ•œ๋‹ค.
  • blink๋Š” text๊ฐ€ ๊นœ๋นก์ด๋Š” ํšจ๊ณผ๋ฅผ ์ ์šฉํ•œ๋‹ค.
<style type = "text/css">
    #none { text-decoration: none; }
    #underline { text-decoration : underline; }
    #underline { text-decoration : overline; }
    #line-through { text-decoration : line-through; }
    #blink { text-decoration : blink; }
    </style>
    </head>
    <body>
        <div id = "none"> none ์†์„ฑ์ด ์ ์šฉ๋œ ๋ฌธ์ž์—ด. </div>
        <div id = "underline"> underline ์†์„ฑ์ด ์ ์šฉ๋œ ๋ฌธ์ž์—ด. </div>
        <div id = "underline"> underline ์†์„ฑ์ด ์ ์šฉ๋œ ๋ฌธ์ž์—ด. </div>
        <div id = "line-through"> line-through ์†์„ฑ์ด ์ ์šฉ๋œ ๋ฌธ์ž์—ด. </div>
        <div id = "blink"> blink ์†์„ฑ์ด ์ ์šฉ๋œ ๋ฌธ์ž์—ด. </div>
    </body>

text-indent

  • Text-block์ธ ์ฒซ ๋ผ์ธ์˜ ๋“ค์—ฌ์“ฐ๊ธฐ ์ง€์ •
  • ์‚ฌ์šฉ๋ฒ•์€ โ€œ E { text-indent: ์ ˆ๋Œ€ ๊ฐ’(px, pt, em, em etc) / ๋ฐฐ์œจ % } โ€œ ์ด๋‹ค.
  • ์ ˆ๋Œ€ ๊ฐ’์˜ ๊ธฐ๋ณธ ๊ฐ’์€ 0 ์ด๋‹ค.
  • ๋ฐฐ์œจ ๊ฐ’์€ ๋ถ€๋ชจ ์—˜๋ฆฌ๋จผํŠธ ๋„ˆ๋น„์˜ ๋น„์œจ๋กœ ๋“ค์—ฌ์“ฐ๊ธฐ ํ•œ๋‹ค.
  • ์†์„ฑ ๊ฐ’์— ์Œ์ˆ˜๋ฅผ ํ—ˆ์šฉํ•œ๋‹ค. ( ์Œ์ˆ˜ ๊ฐ’ ์‚ฌ์šฉ ์‹œ ์™ผ์ชฝ์œผ๋กœ ๋“ค์—ฌ์“ฐ๊ธฐ ํ•œ๋‹ค. )
<style type = "text/css">
    p.positive { text-indent: 1cm; }
    p.negatvie { text-indent: -5px; }
    </style>
    </head>
    <body>
        <p class="positive">
            ๋“ค์—ฌ์“ฐ๊ธฐ๊ฐ€ ์ ์šฉ๋œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.
            text-indent ์‚ฌ์šฉ
            </p>
        <p class="negative">
            ์™ผ์ชฝ ๋“ค์—ฌ์“ฐ๊ธฐ๊ฐ€ ์ ์šฉ๋œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.
            text-indent ์‚ฌ์šฉ
            </p>
    </body>

text-transform

  • text ๋Œ€๋ฌธ์žํ™”
  • ์‚ฌ์šฉ๋ฒ•์€ โ€œ E { text-transform: capitalize / uppercase / lowercase / none } โ€œ ์ด๋‹ค.
  • capitalize ๋Š” ์ฒซ ๊ธ€์ž๋ฅผ ๋Œ€๋ฌธ์ž๋กœ, uppercase ๋Š” ๊ธ€์ž ์ „์ฒด๋ฅผ ๋Œ€๋ฌธ์ž๋กœ, lowercase ๋Š” ๊ธ€์ž ์ „์ฒด๋ฅผ ์†Œ๋ฌธ์ž๋กœ ๋ฐ”๊ฟ”์ค€๋‹ค.
<style type = "text/css">
    .capitalize { text-transform: capitalize; }
    .uppercase { text-transform: uppercase; }
    .lowercase { text-transform: lowercase; }
    </style>
    </head>
    <body>
        <p class= "capitalize">
            capitalize๊ฐ€ ์ ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
            </p>
        <p class="uppercase">
            uppercase๊ฐ€ ์ ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
            </p>
        <p class="lowercase">
            lowercase๊ฐ€ ์ ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
            </p>
    </body>

white-space

  • ์—˜๋ฆฌ๋จผํŠธ ์•ˆ์˜ ๊ณต๋ฐฑ ์ง€์ •
  • ์‚ฌ์šฉ๋ฒ•์€ โ€œ E { white-space: normal / pre / nowrap / pre-line / pre-wrap } โ€œ ์ด๋‹ค.
  • normal์€ ์ •ํ•ด์ง„ ์˜์—ญ์— ๋”ฐ๋ผ ์ค„์ด ๋ฐ”๋€Œ๋ฉฐ, ํ•˜๋‚˜์˜ whitespace๋งŒ ํ—ˆ์šฉํ•œ๋‹ค.
  • pre๋Š” <pre> ์ฒ˜๋Ÿผ ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ๋ชจ์Šต ๊ทธ๋Œ€๋กœ ๊ณต๋ฐฑ์„ ํ™”๋ฉด์— ์ถœ๋ ฅํ•œ๋‹ค.
  • nowrap์€ ํ•˜๋‚˜์˜ whitespace๋งŒ ํ—ˆ์šฉํ•˜๋ฉฐ ์ค„ ๋ฐ”๊ฟˆ ๊ธˆ์ง€. ( <br> ๋งŒ๋‚˜๊ธฐ ์ „๊นŒ์ง€ ๊ฐ™์€ ์ค„์— ์ถœ๋ ฅํ•œ๋‹ค. )
<style type = "text/css">
        .white1 { white-space: normal; }
        .white2 { white-space: pre; }
        .white3 { white-space: nowrap; }
        </style>
        </head>
        <body>
            <!-- ๋งˆ์šฐ์Šค๋ฅผ ์œ„์— ์˜ฌ๋ฆฌ๋ฉด white2 ์‹คํ–‰
                 ๋งˆ์šฐ์Šค๋ฅผ ๋ˆ„๋ฅด๋ฉด white3 ์‹คํ–‰
                 ๋‹ค์‹œ ๋Œ์•„์˜ค๋ฉด white1 ์‹คํ–‰ -->
            <p class= "white1"
            onmouseover ="this.className='white2'"
            onmousedown ="this.className='white3'"
            onmouseout ="this.className='white1'">
            basic : white1, mouseover : white2, mousedown : white3,
            mouseout : white1, white-space ์†์„ฑ : normal, pre, nowrap, pre-line, pre-wrap
            </p>
        </body>

letter-spacing

<style type = "text/css">
        .letter { letter-spacing: 5px; }
        </style>
        </head>
        <body>
            <div class= "letter">๊ธ€์ž๊ฐ„์˜ ๊ฐ„๊ฒฉ์„ ์กฐ์ ˆํ•ฉ๋‹ˆ๋‹ค. </div>
        </body>

word-spacing

<style type = "text/css">
        .word { word-spacing: -10px; }
        </style>
        </head>
        <body>
            <div class= "word">๋‹จ์–ด๊ฐ„์˜ ๊ฐ„๊ฒฉ์„ ์กฐ์ ˆํ•ฉ๋‹ˆ๋‹ค. </div>
        </body>

line-height

  • ์ค„(ํ–‰) ๊ฐ„๊ฒฉ ์ง€์ •
  • ์‚ฌ์šฉ๋ฒ•์€ โ€œ E { line-height: ์ƒ๋Œ€ ๊ฐ’ / ์ ˆ๋Œ€ ๊ฐ’ / ๋น„์œจ } โ€œ ์ด๋‹ค.
  • ๋น„์œจ ๊ฐ’์„ ์‚ฌ์šฉํ•˜๋ฉด ํ˜„์žฌ ๊ธ€์ž ํฌ๊ธฐ๋ฅผ ๊ธฐ๋ณธ์œผ๋กœ 50%, 200% ๊ฐ™์€ ๋น„์œจ๋กœ ํ–‰ ๊ฐ„๊ฒฉ์„ ์„ค์ •ํ•œ๋‹ค.
  • ์ ˆ๋Œ€ ๊ฐ’์„ ์‚ฌ์šฉํ•˜๋ฉด ํ–‰ ๊ฐ„๊ฒฉ์„ px, cm ๋“ฑ์œผ๋กœ ์ง์ ‘ ์„ค์ •ํ•œ๋‹ค.
  • ์ƒ๋Œ€ ๊ฐ’์„ ์‚ฌ์šฉํ•˜๋ฉด ํ˜„์žฌ ๊ธ€์ž ํฌ๊ธฐ์— ์ƒ๋Œ€ ๊ฐ’์„ ๊ณฑํ•œ ์ˆ˜ ๋งŒํผ ํ–‰ ๊ฐ„๊ฒฉ์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.
<style type = "text/css">
    p {line-height: normal; color: red; }
        .small { line-height: 0.7; color:orange; }
        .big { line-height: 4; color:yellow; }
        </style>
        </head>
        <body>
            <p> ๊ธฐ๋ณธ ํ–‰ ๊ฐ„๊ฒฉ์ž…๋‹ˆ๋‹ค.</p>
            <p class="small"  > small ํ–‰ ๊ฐ„๊ฒฉ์ž…๋‹ˆ๋‹ค.</p>
            <p class="big"> big ํ–‰ ๊ฐ„๊ฒฉ์ž…๋‹ˆ๋‹ค.</p>
        </body>

CSS Font & Text ๋งˆ๋ฌด๋ฆฌ

CSS ์—์„œ ์‚ฌ์šฉ ๋˜๋Š” Font์™€ Text์— ๋Œ€ํ•ด์„œ ์•Œ์•„ ๋ณด์•˜๋‹ค.
๋งŽ์€ ์†์„ฑ๋“ค์ด ์žˆ๋Š”๋ฐ ์–ด๋ ค์šด ๊ฒƒ๋“ค์€ ์—†์–ด์„œ ์ด๋Ÿฐ๊ฒŒ ์žˆ๊ตฌ๋‚˜ ํ•˜๊ณ  ๋„˜์–ด๊ฐ”๋‹ค.
๊ทธ๋ž˜๋„ ์ •๋ฆฌ๋ฅผ ํ•œ๋ฒˆ ํ•จ์œผ๋กœ์จ ๋‚˜์ค‘์— ์‚ฌ์šฉํ•  ๋•Œ ์ข€ ๋” ํŽธํ•  ๊ฒƒ ๊ฐ™๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์‹ค์Šต๋“ค์„ ํ•ด๋ด„์œผ๋กœ์จ ์–ด๋–ค ์†์„ฑ๋“ค์ธ์ง€ ์•Œ๊ฒŒ ๋œ ๊ฒƒ ๊ฐ™๋‹ค.