์ ๋ ฌ์ ๋ํ์! ํ๋ ์ค ํด๋ฒ๋ฆฐ ํ๋ ์ค๋ฐ์ค๋ ๊ทธ๊ฐ CSS ์ ๋ ฌ์ ์ด๋ ค์์ ๊นจ๋ฒ๋ ธ๋ค. ์์๋๋ฉด ์ธ๋ชจ ๋ง์ flex. 'How to use it?'๋ฅผ ์ ์๊ณ ์ ํ์ฉํ์
display: flex; / inline-flex;
'reverse'๋ ์์ ๋ฐฉํฅ ๋ฟ ์๋๋ผ ์์ฑ์ ์์๋ ๋ฐ๊พผ๋ค.
main axis ๊ธฐ์ค ์์ดํ
์ ๋ ฌ
- justify-content: flex-start(์์์ *๊ธฐ๋ณธ๊ฐ), flex-end(๋ ์ ), ์ผํฐ(๊ฐ์ด๋ฐ ์ ๋ ฌ), space-between(๊ฐ๊ฒฉ ๋ํ๊ธฐ), space-around(๊ท ์ผํ๊ฒ ์ ์์ผ๋ก ๋ํ๊ธฐ)
cross axis ๊ธฐ์ค ์์ดํ
์ ๋ ฌ
- align-items: flex-start(*๊ธฐ๋ณธ๊ฐ), flex-end, ์ผํฐ
- align-content
flexwrap: wrap;
์ผ ๊ฒฝ์ฐ flex line์ด 2๊ฐ๊ฐ ์๊ธฐ๋๋ฐ, ์์์ ์์ ์ฌ์ด์ ๊ฐ๊ฒฉ์ ์กฐ์ ํ ๋ ์ด๋ค. order: 1;
order: 2;
์ ๊ฐ์ด ๊ฐ์ ์ง์ ํด์ฃผ๋ฉด ์์์ ์๊ด์์ด order๊ฐ์ผ๋ก ๋ฐฐ์ด๋จ* {
box-sizing: border-box;
margin: 0;
}
body {
font-family: "Muli", sans-serif;
color: #273444;
background-color: blue;
}
.profile-name {
font-size: 18px;
font-weight: 600;
line-height: 1.3333333333;
}
.profile-location {
font-size: 14px;
line-height: 1.4285714286;
color: #8492a6;
}
.profile-detail dt {
font-size: 12px;
font-weight: 600;
line-height: 1.6666666667;
color: #8492a6;
}
.profile-detail dd {
font-size: 32px;
font-weight: 300;
line-height: 1.25;
color: #0066ff;
}
body {
width: 100%;
height: 100vh;
display: flex;
justify-content: cente;
align-items: cente;
}
.profile {
display: flex;
flex-direction: column;
align-items: cente;
width: 386px;
padding: 32px 40px;
border-radius: 16px;
text-align: cente;
background-color: #FFFFFF;
}
.profile-image {
width: 80px;
height: 80px;
border-radius: 50%;
margin-bottom: 16px;
}
.profile-name {
margin-bottom: 4px;
}
.profile-location {
margin-bottom: 32px;
}
.profile-detail {
display: flex;
justify-content: space-between;
align-items: cente;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flexbox-3</title>
<link href="https://fonts.googleapis.com/css?family=Muli:300,400,600&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="style.css">
</head>
<body>
<section class="profile">
<img src="./assets/user.jpg" alt="Noah Mdsen" class="profile-image"/>
<h1 class="profile-name">Noah madsen</h1>
<p class="profile-location">Copenhagen, Denmark</p>
<dl class="profile-detail">
<div class="profile-detail-item">
<dt>Friends</dt>
<dd>730</dd>
</div>
<div class="profile-detail-item">
<dt>Projects</dt>
<dd>3</dd>
</div>
<div class="profile-detail-item">
<dt>Reviews</dt>
<dd>243</dd>
</div>
</dl>
</section>
</body>
</html>
body {
width: 100%;
height: 100vh;
display: flex;
justify-content: cente;
align-items: cente;
}
์ถ์ฒ: '๊น๋ฒ๊ทธ์ HTML&CSS๋ ์ฌ๋ฐ๋ค'๋ฅผ ํ์ตํ๊ณ ์ ๋ฆฌํ ๋ด์ฉ์ ๋๋ค.