๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๊ฐœ์ธ๊ณต๋ถ€/HTML5 + CSS3

[HTML+CSS][ํ”Œ๋ ‰์Šค ๋ฐ•์Šค ๋ ˆ์ด์•„์›ƒ] 02 - ํ”Œ๋ ‰์Šค ๋ฐ•์Šค ํ•ญ๋ชฉ ๋ฐฐ์น˜๋ฅผ ์œ„ํ•œ ์†์„ฑ๋“ค

by ๐Ÿ‡๋ฐ•๋ด‰๋ด‰๐Ÿ‡ 2020. 8. 11.

 

 

[HTML+CSS][ํ”Œ๋ ‰์Šค ๋ฐ•์Šค ๋ ˆ์ด์•„์›ƒ] 01 - ํ”Œ๋ ‰์Šค ๋ฐ•์Šค ๋ ˆ์ด์•„์›ƒ๊ณผ ๊ธฐ๋ณธ ์†์„ฑ๋“ค

[HTML+CSS][๋ฏธ๋””์–ด ์ฟผ๋ฆฌ] 03 - ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•ด ์›น ๋ฌธ์„œ ๋งŒ๋“ค๊ธฐ [HTML+CSS][๋ฏธ๋””์–ด ์ฟผ๋ฆฌ] 02 - ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ ์ ์šฉํ•˜๊ธฐ [HTML+CSS][๋ฏธ๋””์–ด ์ฟผ๋ฆฌ] 01 - ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ ์ดํ•ดํ•˜๊ธฐ [HTML+CSS][๋ฐ˜์‘ํ˜• ์›น] 03 - ๊ฐ€๋ณ€..

onelight-stay.tistory.com

 

ํ”Œ๋ ‰์Šค ๋ฐ•์Šค ํ•ญ๋ชฉ์„ ๋ฐฐ์น˜ํ•˜๊ธฐ ์œ„ํ•œ ์†์„ฑ๋“ค์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๋„๋ก ํ•˜์ž.

 

 


 

 

justify-content ์†์„ฑ - ์ฃผ์ถ• ๊ธฐ์ค€์˜ ๋ฐฐ์น˜ ๋ฐฉ๋ฒ• ์ง€์ •

 

๋ฐ˜์‘ํ˜• ์›น ๋””์ž์ธ์„ ์œ„ํ•ด ๊ฐ€๋ณ€ ๊ทธ๋ฆฌ๋“œ ๋ ˆ์ด์•„์›ƒ ์‚ฌ์šฉ ์‹œ

๊ธ€์ž ํฌ๊ธฐ๋„ ์œ ๋™์ ์œผ๋กœ ๋ฐ”๋€Œ๋Š” ๊ฒƒ์ด๋‹ค.

 

 


 

 

align-items ์†์„ฑ, align-self ์†์„ฑ - ๊ต์ฐจ์ถ• ๊ธฐ์ค€์˜ ๋ฐฐ์น˜ ๋ฐฉ๋ฒ• ์ง€์ •

 

๊ต์ฐจ์ถ•์„ ๊ธฐ์ค€์œผ๋กœ ๋ฐฐ์น˜ ๋ฐฉ๋ฒ•์„ ์กฐ์ ˆํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

 

 

align-self ์†์„ฑ์„ ์ด์šฉํ•˜๋ฉด ํ”Œ๋ ‰์Šค ํ•ญ๋ชฉ์„ ๊ฐœ๋ณ„์ ์œผ๋กœ ๋ฐฐ์น˜ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

align-self๋Š” ํ”Œ๋ ‰์Šค ํ•ญ๋ชฉ์˜ ๋ถ€๋ชจ ์†์„ฑ ๊ฐ’์„ ๋ฐ›๋Š” auto ๊ฐ’์„ ์ œ์™ธํ•˜๋ฉด

align-items์—์„œ์˜ ์†์„ฑ๊ฐ’๊ณผ ๊ฐ™๋‹ค.

 

 

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>๊ต์ฐจ์ถ•์˜ ๋ฐฐ์น˜ ๋ฐฉ๋ฒ• ์ง€์ •ํ•˜๊ธฐ</title>
    <style>
        #container {
            width: 500px;
            height: 100px;
            margin: 0 auto 20px;
            display: flex;
            align-items: center; /* ๊ต์ฐจ์ถ• ๊ธฐ์ค€์˜ ๋ฐฐ์น˜๋ฐฉ๋ฒ• ์„ค์ • */
            border: 2px solid black;
        }
        #container div {
            width: 100px;
            border: 2px black solid;
            background: lightgray;
        }
        #box1 { /* box1์˜ ๋ฐฐ์น˜๋งŒ ๋”ฐ๋กœ ์„ค์ • */
            align-self: flex-start;
        }
        p {
            font-weight: bold;
            text-align: center;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div id="container">
        <div id="box1"><p>1</p></div>
        <div id="box2"><p>2</p></div>
        <div id="box3"><p>3</p></div>
    </div>
</body>
</html>

 

 


 

 

align-content ์†์„ฑ - ์—ฌ๋Ÿฌ ์ค„์ผ ๋•Œ์˜ ๋ฐฐ์น˜ ๋ฐฉ๋ฒ• ์ง€์ •

 

ํ”Œ๋ ‰์Šค ํ•ญ๋ชฉ์ด ์—ฌ๋Ÿฌ ์ค„์— ๊ฑธ์ณ ํ‘œ์‹œ๋  ๋•Œ

align-content ์†์„ฑ์„ ์‚ฌ์šฉํ•˜๋ฉด ๊ต์ฐจ์ถ• ๋ฐฉํ–ฅ์˜ ๋ฐฐ์ฐจ ๋ฐฉ๋ฒ•์„

์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>align-content</title>
    <style>
        .box {
            width: 500px;
            height: 150px;
            margin: 0 auto 20px;
            display: flex;
            -ms-flex-wrap: wrap;
            -webkit-flex-wrap: wrap;
            flex-wrap: wrap;
            border: 2px solid black;
        }
        #container1 {
            -ms-align-content: flex-start;
            -webkit-align-content: flex-start;
            align-content: flex-start;
        }
        #container2 {
            -ms-align-content: flex-end;
            -webkit-align-content: flex-end;
            align-content: flex-end;
        }
        #container3 {
            -ms-align-content: center;
            -webkit-align-content: center;
            align-content: center;
        }
        #container4 {
            -ms-align-content: space-between;
            -webkit-align-content: space-between;
            align-content: space-between;
        }
        #container5 {
            -ms-align-content: space-around;
            -webkit-align-content: space-around;
            align-content: space-around;
        }
        .box div {
            width: 200px;
            border: black solid 2px;
            background: lightgray;
        }
        h1 {text-align: center;}
        p {
            font-weight: bold;
            text-align: center;
            font-weight: bold;
        }

    </style>
</head>
<body>
    <h1>align-content : flex-start (๊ธฐ๋ณธ๊ฐ’)</h1>
    <div id="container1" class="box">
        <div><p>1</p></div>
        <div><p>2</p></div>
        <div><p>3</p></div>
    </div>
    <h1>align-content : flex-end</h1>
    <div id="container2" class="box">
        <div><p>1</p></div>
        <div><p>2</p></div>
        <div><p>3</p></div>
    </div>
    <h1>align-content : center</h1>
    <div id="container3" class="box">
        <div><p>1</p></div>
        <div><p>2</p></div>
        <div><p>3</p></div>
    </div>
    <h1>align-content : space-between</h1>
    <div id="container4" class="box">
        <div><p>1</p></div>
        <div><p>2</p></div>
        <div><p>3</p></div>
    </div>
    <h1>align-content : space-around</h1>
    <div id="container5" class="box">
        <div><p>1</p></div>
        <div><p>2</p></div>
        <div><p>3</p></div>
    </div>
</body>
</html>

 

 


 

 

ํ”Œ๋ ‰์Šค ๋ฐ•์Šค ํ•ญ๋ชฉ ๋ฐฐ์น˜๋ฅผ ์ข€ ๋” ๋‹ค์–‘ํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ๋Š” ์†์„ฑ๋“ค์ด๋ผ์„œ ๊ทธ๋Ÿฐ์ง€

์–‘๋„ ๋งŽ๊ณ  ์™ธ์›Œ์•ผ ํ•  ๊ฒƒ๋“ค์ด ์‚ฐ๋”๋ฏธ์ธ ๊ฒƒ ๊ฐ™๋‹ค.

 

์ฐจ๊ทผ์ฐจ๊ทผ ์™ธ์›Œ์„œ ํ•„์š”ํ•  ๋•Œ ๊ผญ ์จ๋จน์–ด์•ผ๊ฒ ๋‹ค.

 

 


 

 

< ์ฐธ๊ณ  >

Do it! HTML5+CSS3 ์›น ํ‘œ์ค€์˜ ์ •์„

 

 

โ€ป ํ•ด๋‹น ๊ธ€์€ ์Šต๋“ ๋ชฉ์ ์œผ๋กœ ์ž‘์„ฑ๋œ ๊ธ€์ž…๋‹ˆ๋‹ค โ€ป

 

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€