demo_03.html
0.00MB
demo_04.html
0.00MB
๐ก ํ์ต ๋ชฉํ
- ์ฃผ ์ถ(main axis)๊ณผ ๊ต์ฐจ ์ถ(cross axis)
- flex-direction: row, row-reverse, column, column-reverse
FlexBox์ ๋ ๊ฐ์ ์ถ
flexbox ๋ ์ด์์์ ์ ๋ ฌ์ ์ดํดํ๋๋ฐ ๊ฐ์ฅ ์ค์ํ ์ญํ ์ ํ๊ฒ ๋ฉ๋๋ค.
์ฃผ์ถ( main axis)์ ๋ฐฉํฅ๊ณผ ๊ต์ฐจ์ถ (cross axis )์ ๋ฐฉํฅ์ ๊ฒฐ์ ํ๋ flex-direction ์ด๋ผ๋ ์์ฑ์ด ์์ต๋๋ค.
flex-direction์ ๊ธฐ๋ณธ๊ฐ์ row์ ๋๋ค.
- ์ฃผ์ถ ๋ฐฉํฅ(main axis)
Flex container์ ์ ์ธ๋ flex-direction์ ๊ฐ์ ๋ฐ๋ผ ์์ ์์์ธ flex item์ด ๋์ด๋๋ ๋ฐฉํฅ์ ๋๋ค.
flex-direction:row ์ธ ๊ฒฝ์ฐ๋ ์ฃผ์ถ์ด ์ํ์ด ๋๊ณ flex-direction:column์ธ ๊ฒฝ์ฐ๋ ์ฃผ์ถ์ด ์์ง ๋ฐฉํฅ์ด ๋ฉ๋๋ค. - ๊ต์ฐจ์ถ ๋ฐฉํฅ(cross axis )
Flex container์ ์ฃผ์ถ์ ์ง๊ฐ์ ์ด๋ฃจ๋ ์ถ์ผ๋ก ์ฃผ์ถ์ด ์ํ์ด๋ฉฐ ๊ต์ฐจ์ถ์ ์์ง ๋ฐฉํฅ์ด ๋ฉ๋๋ค.


flex-direction ์์ฑ์ด๋?
flex-direction ์์ฑ์ ์ฃผ ์ถ์ ๋ฐฉํฅ์ ์ค์ ํฉ๋๋ค.
- row: ์์ดํ ๋ค์ ์ํ์ผ๋ก ๋ฐฐ์นํฉ๋๋ค (๊ธฐ๋ณธ๊ฐ).
- row-reverse: ์์ดํ ๋ค์ ์ํ์ผ๋ก ๋ฐฐ์นํ๋, ๋ฐ๋ ๋ฐฉํฅ์ผ๋ก ๋ฐฐ์นํฉ๋๋ค.
- column: ์์ดํ ๋ค์ ์์ง์ผ๋ก ๋ฐฐ์นํฉ๋๋ค.
- column-reverse: ์์ดํ ๋ค์ ์์ง์ผ๋ก ๋ฐฐ์นํ๋, ๋ฐ๋ ๋ฐฉํฅ์ผ๋ก ๋ฐฐ์นํฉ๋๋ค.



demo_03.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>์ธ๋ผ์ธ ๋ธ๋ก์์ ์์</title>
<!-- title์ ๋ณด์ด์ง ์๋๋ค. -->
<style type="text/css">
.container {
display: flex;
border: 1px solid black;
flex-direction: row;
}
.item {
background-color: lightblue;
padding: 10px;
margin: 5px;
border: 1px solid blue;
}
</style>
</head>
<body>
<!-- http://localhost:8080/demo1/demo_03.html -->
<h1>์ฌ๊ธฐ๋ demo_03.html ํ์ผ ์
๋๋ค.</h1>
<h3>flex-direction : row(๊ธฐ๋ณธ๊ฐ)</h3>
<div class = "container">
<div class = "item">์์ดํ
1</div>
<div class = "item">์์ดํ
2</div>
<div class = "item">์์ดํ
3</div>
</div>
<h3>flex-direction : row-reverse</h3>
<div class = "container" style="flex-direction: row-reverse;">
<div class = "item">์์ดํ
1</div>
<div class = "item">์์ดํ
2</div>
<div class = "item">์์ดํ
3</div>
</div>
<h3>flex-direction : column</h3>
<div class = "container" style="flex-direction: column;">
<div class = "item">์์ดํ
1</div>
<div class = "item">์์ดํ
2</div>
<div class = "item">์์ดํ
3</div>
</div>
<h3>flex-direction : column-reverse</h3>
<div class = "container" style="flex-direction: column-reverse;">
<div class = "item">์์ดํ
1</div>
<div class = "item">์์ดํ
2</div>
<div class = "item">์์ดํ
3</div>
</div>
</body>
</html>

์๋๋ฆฌ์ค ์ฝ๋ 2
์ต์ปค ํ๊ทธ๋ฅผ ์ฌ์ฉํ์ฌ ํ์ด์ง ๋ด ํน์ ์์น๋ก ์ด๋ํ ์ ์์ต๋๋ค.
demo_04.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>์ธ๋ผ์ธ ๋ธ๋ก์์ ์์</title>
<!-- title์ ๋ณด์ด์ง ์๋๋ค. -->
<style type="text/css">
.navbar {
display: flex;
border: 1px solid black;
background-color: #f8f9fa;
padding: 10px;
}
.navbar2 {
display: flex;
border: 1px solid black;
background-color: #f8f9fa;
padding: 10px;
flex-direction: column;
}
.navbar3 {
display: flex;
border: 3px black;
padding: 10px;
}
.nav-item {
margin: 5px;
padding: 10px;
background-color: lightblue;
color: white;
text-align: center;
border-radius: 4px;
text-decoration: none;
}
.section {
height: 300px;
padding: 20px;
margin-top: 20px;
border: 1px solid #000;
}
</style>
</head>
<body>
<!-- http://localhost:8080/demo1/demo_04.html -->
<h1>์ฌ๊ธฐ๋ demo_04.html ํ์ผ ์
๋๋ค.</h1>
<br>
<h2>flex-direction: row</h2>
<div class="navbar">
<a href="#home" class="nav-item">ํ</a>
<a href="#about" class="nav-item">์๊ฐ</a>
<a href="#services" class="nav-item">์๋น์ค</a>
<a href="#contact" class="nav-item">์ฐ๋ฝ์ฒ</a>
</div>
<h2>flex-direction: column</h2>
<div class="navbar2">
<a href="#home" class="nav-item">ํ</a>
<a href="#about" class="nav-item">์๊ฐ</a>
<a href="#services" class="nav-item">์๋น์ค</a>
<a href="#contact" class="nav-item">์ฐ๋ฝ์ฒ</a>
</div>
<div class="section" id="home">
<h2>ํ ์น์
</h2>
<p>์ฌ๊ธฐ๋ ํ ์น์
์์ญ์
๋๋ค.</p>
</div>
<div class="section" id="about">
<h2>์๊ฐ ์น์
</h2>
<p>์ฌ๊ธฐ๋ ์๊ฐ ์น์
์์ญ์
๋๋ค.</p>
</div>
<div class="section" id="services">
<h2>์๋น์ค ์น์
</h2>
<p>์ฌ๊ธฐ๋ ์๋น์ค ์น์
์์ญ์
๋๋ค.</p>
</div>
<div class="section" id="contact">
<h2>์ฐ๋ฝ์ฒ ์น์
</h2>
<p>์ฌ๊ธฐ๋ ์ฐ๋ฝ์ฒ ์น์
์์ญ์
๋๋ค.</p>
</div>
</body>
</html>

'HTML CSS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| 2024.07.04 CSS flexbox ์ค๊ฐ ์ ๊ฒ - ์ฐ์ต ๋ฌธ์ (๋ฏธ์์ฑ) (0) | 2024.07.04 |
|---|---|
| 2024.07.04 CSS flexbox FlexItem์ ์ธ๋ฐํ ์ ์ด flex ์์ฑ (0) | 2024.07.04 |
| 2024.07.02 CSS flexbox ๊ต์ฐจ์ถ ์ ๋ ฌ์๋ align-items์ align-content ์ด๋ค. (0) | 2024.07.02 |
| 2024.07.02 CSS flexbox ์ฃผ์ถ ๋ฐฉํฅ ์ ๋ ฌ justify-content ๋? (0) | 2024.07.02 |
| 2024.07.01 CSS flexbox Flexbox ๋? (0) | 2024.07.01 |