vscode 가운데정렬 오류 한번만 봐주세요
본문
<!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>Document</title>
<style>
* {margin:0; padding:0;}
div.content div{ margin: 0 auto;}
.box1 {background-color: red;
width:200px; height:50px;
line-height:50px;}
.box2 {background-color: orange;
width:25px; height:90px;}
.box3 {background-color: yellow;
width:145px; height:90px;}
.box4 {background-color: green;
width:30px ; height:45px;}
.box5 {background-color: blue;
width:30px; height:45px;}
.box6 {background-color: purple;
width:200px; height:50px;
line-height:50px;
clear: both;}
.warpA {overflow: hidden;}
.wrapB {line-height: 90px;
float: left;
display:flex;}
.wrapC {line-height: 45px;
float: left;}
</style>
</head>
<body>
<div class="content">
<div class="box1">1</div>
<div class="wrapA">
<div class="wrapB">
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<div class="wrapC">
<div class="box4">4</div>
<div class="box5">5</div>
</div>
</div>
<div class="box6">6</div>
</div>
</body>
</html>
1,2,3,4,5,6 상자가 모두 가운데로 이동해야 하는데 2,3,4,5 상자는 움직이지 않아요..
아무리 해봐도 모르겠어요..
!-->
답변 1
<style>
* {margin:0; padding:0;}
div.content{display:flex;align-items:center;flex-direction:column;}
.box1 {background-color: red;width:200px; height:50px;line-height:50px;}
.box2 {background-color: orange;width:25px; height:90px;}
.box3 {background-color: yellow;width:145px; height:90px;}
.box4 {background-color: green;width:30px ; height:45px;}
.box5 {background-color: blue;width:30px; height:45px;}
.box6 {background-color: purple;width:200px; height:50px;line-height:50px;clear: both;}
.wrapA {overflow: hidden;display:flex;}
.wrapB {line-height: 90px;display:flex;}
.wrapC {line-height: 45px;}
</style>
https://codepen.io/hs-feelz/pen/JjmjgZP
위와 같이 나오길 원하시는게 맞나요?
답변을 작성하시기 전에 로그인 해주세요.