๐ก
์ฃผ ์ถ(main axis)๊ณผ ๊ต์ฐจ ์ถ(cross axis)
flex-direction: row, row-reverse, column, column-reverse
flexbox ๋ ์ด์์์ ์ ๋ ฌ์ ์ดํดํ๋๋ฐ ๊ฐ์ฅ ์ค์ํ ์ญํ ์ ํ๊ฒ ๋๋ค.
์ฃผ์ถ( main axis)์ ๋ฐฉํฅ๊ณผ ๊ต์ฐจ์ถ (cross axis )์ ๋ฐฉํฅ์ ๊ฒฐ์ ํ๋ flex-direction ์ด๋ผ๋ ์์ฑ์ด ์๋ค.
flex-direction์ ๊ธฐ๋ณธ๊ฐ์ row์ ๋๋ค.
1
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>์ธ๋ผ์ธ์์์ํจ๋ฉ๊ทธ๋ฆฌ๊ณ ๋ง์ง</title>
<style type="text/css">
.m-inline{
background-color:lightgreen;
padding: 10px;
margin-top: 200px;
margin-left: 20px;
margin-right: 20px;
border: 1px solid red;
}
</style>
</head>
<body>
<!-- http://localhost:8080/demo1/ -->
<h1>์ฌ๊ธฐ๋ demo_01.html ํ์ผ์
๋๋ค.</h1>
<p>
์ด ํ
์คํธ๋ <span class="m-inline">์ธ๋ผ์ธ ์์ 1</span>์
๋๋ค.
์ด ํ
์คํธ๋ <span class="m-inline">์ธ๋ผ์ธ ์์ 2</span>์
๋๋ค.
</p>
</body>
</html>
2
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>์ธ๋ผ์ธ๋ธ๋ก ์์ ์์</title>
<style type="text/css">
.m-inline-block{
display: inline-block;
background-color: aqua;
padding: 10px;
margin: 10px;
}
</style>
</head>
<body>
<!-- http://localhost:8080/demo1/demo_02.html -->
<h1>์ฌ๊ธฐ๋ demo_02.html ํ์ผ์
๋๋ค.</h1>
<div class="m-inline-block">์ธ๋ผ์ธ ๋ธ๋ก ์์1</div>
<div class="m-inline-block">์ธ๋ผ์ธ ๋ธ๋ก ์์2</div>
</body>
</html>
3
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<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>
<br>
<h3>flex-directioon : row(๊ธฐ๋ณธ๊ฐ)</h3>
<div class="container">
<div class="item">์์ดํ
1</div>
<div class="item">์์ดํ
2</div>
<div class="item">์์ดํ
3</div>
</div>
<h3>flex-directioon : 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-directioon : 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-directioon : 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>
4 - ์ต์ปค ํ๊ทธ๋ฅผ ์ฌ์ฉํ์ฌ ํ์ด์ง ๋ด ํน์ ์์น๋ก ์ด๋ํ ์ ์๋ค.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>์ธ๋ผ์ธ ๋ธ๋ก ์์ ์์</title>
<style type="text/css">
.navbar1{
display:flex;
border: 1px solid black;
background-color: #f8f9fa;
padding: 10px;
}
.nav-item1{
margin:5px;
padding:10px;
background-color:lightblue;
color: white;
text-align: center;
border-radius:4px;
text-decoration: none;
}
.navbar2{
display:flex;
border: 1px solid black;
background-color: #f8f9fa;
padding: 10px;
flex-direction: column;
}
.nav-item2{
margin:5px;
padding:10px;
background-color:lightblue;
color: white;
text-align: center;
border-radius:4px;
text-decoration: none;
}
.content1{
margin: 10px;
display:flex;
border: 1px solid gray;
padding: 10px;
}
.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="navbar1">
<a href="#home" class="nav-item1">ํ</a>
<a href="#about" class="nav-item1">์๊ฐ</a>
<a href="#services" class="nav-item1">์๋น์ค</a>
<a href="#contact" class="nav-item1">์ฐ๋ฝ์ฒ</a>
</div>
<h2>flex-direction: column</h2>
<div class="navbar2">
<a href="#home" class="nav-item2">ํ</a>
<a href="#about" class="nav-item2">์๊ฐ</a>
<a href="#services" class="nav-item2">์๋น์ค</a>
<a href="#contact" class="nav-item2">์ฐ๋ฝ์ฒ</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>
ํด๋ฆญํ๋ฉด ์ํ๋ ์น์ ์ผ๋ก ์ด๋์ด ๊ฐ๋ฅํ๋ค
์์ ๋ณด๋ฉด #services๋ผ๊ณ ๋จ๋ ๊ฒ๋ ํ์ธํ ์ ์๋ค
๊ทธ๋ผ ์๊น style="flex-direction: column;"์ ์ฌ์ฉํด์ ๋ฐฉํฅ์ column์ผ๋ก ๋ฐ๊ฟจ๋๋ฐ ๊ทธ๋ผ ์ด๋ ๊ฒ ์ฌ์ฉํ๋ฉด ์๋ ๊น? ๋ฐ๋ก class๋ฅผ ๋ง๋ค์ด์ค์ผ ๋ ๊น?
์ด๋ ๊ฒ๋ ์ฌ์ฉ ๊ฐ๋ฅํ๋ค๐
flex-wrap ์ดํดํ๊ธฐ (0) | 2024.07.04 |
---|---|
css ๊ณต๋ถ (0) | 2024.07.02 |
[CSS] Flexbox๋? (0) | 2024.07.01 |