๐ gap
- ์์ดํ ๊ฐ์ ๊ฑฐ๋ฆฌ๋ฅผ ์ค์ ํ๋ ์์ฑ
- justify-content๋ณด๋ค ๊ตฌ์ฒด์ ์ผ๋ก ์ค์ ํ ์ ์๋ค.
- px, rem/em, %๋ฑ ๋ชจ๋ ๋จ์๋ก ์ค์ ๊ฐ๋ฅํ๋ค.
/* ๋ชจ๋ ๋ฉด์ ๋์ผํ๊ฒ ์ ์ฉ */
.flex-wrap {display: flex; gap: 10px;}
/* ์์๋, ์ข์ฐ */
.flex-wrap {display: flex; gap: 2% 10rem;}
์ ์ฉ ์์ ์ฝ๋
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>flex์ gap ์ฌ์ฉํ๊ธฐ</title>
<link rel="stylesheet" href="/css/reset.css">
<style>
body {text-align: center; background-color: #eee; font-size: 10px;}
h1 {margin-top: 10rem; font-size: 2rem;}
.container { margin: 0 auto; max-width: 1200px; padding: 1rem; background-color: #fff;
border: 1px solid #ccc;}
.flex-wrap {display: flex; flex-wrap: wrap; gap: 10px 5%;}
.obj {width: 10rem; height: 10rem; display: block;}
.obj:nth-child(1),.obj:nth-child(8) {background-color: #f57fb0;}
.obj:nth-child(2),.obj:nth-child(9) {background-color: #fdaa57;}
.obj:nth-child(3),.obj:nth-child(10) {background-color: #fbd65c;}
.obj:nth-child(4),.obj:nth-child(11) {background-color: #b5e868;}
.obj:nth-child(5),.obj:nth-child(12) {background-color: #7deed8;}
.obj:nth-child(6),.obj:nth-child(13) {background-color: #60cff7;}
.obj:nth-child(7),.obj:nth-child(14) {background-color: #7e8ffb;}
</style>
</head>
<body>
<h1>flex์ gap ์ฌ์ฉํ๊ธฐ</h1>
<div class="container">
<div class="flex-wrap">
<div class="obj"></div>
<div class="obj"></div>
<div class="obj"></div>
<div class="obj"></div>
<div class="obj"></div>
<div class="obj"></div>
<div class="obj"></div>
<div class="obj"></div>
<div class="obj"></div>
<div class="obj"></div>
<div class="obj"></div>
<div class="obj"></div>
</div>
</div>
</body>
</html>
๊ฒฐ๊ณผ
See the Pen Untitled by yurim99 (@yurim99) on CodePen.
'Css' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
cubic-bezier (1) | 2023.12.21 |
---|---|
Css๋ก ์ ๋๋ฉ์ด์ ๊ตฌํํ๊ธฐ (1) | 2023.12.20 |
media qurey ๋ฐ์ํ (0) | 2023.12.15 |
Css ํฐํธ ์ ์ฉ ๋ฐฉ๋ฒ๊ณผ ์ข ๋ฅ (0) | 2023.12.12 |
<li>ํ๊ทธ marker ์ ๊ฑฐํ๊ธฐ (0) | 2023.10.13 |