• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

flex로 가운데 정렬을 하고 싶은데 어디를 수정해야 하나요?

22.01.04 16:01 작성 조회수 112

1

html
<html>
  <head>
    <title>market</title>
    <link href="index.css" type="text/css" rel="stylesheet" />
    <script></script>
  </head>
  <body>
    <div id="header"></div>

    <div id="parent">

      <div id="body">
        <div id="banner">배너이미지</div>
        <h1>판매되는 상품들</h1>
        <div id="productlist"></div>
      </div>
     
    </div>

    <div id="footer"></div>
  </body>
</html>
css
#header {
  height: 64px;
  background-color: black;
}
#parant {
  display: flex;
  flex-direction: row;
}

#body {
  justify-content: center;
  width: 1024;
  height: 100%;
  background-color: blue;
}

#footer {
  height: 200px;
  background-color: red;
}
#banner {
  height: 300px;
  background-color: yellow;
}
부모를 만들고 body를 자식으로 넣고
부모에 display:flex를 적용
자식인 body에 justifiy-content:center를 적용했는데
생각처럼 작동을 안해요... 어디서 수정을 해야 할까요?
 
 
 

답변 2

·

답변을 작성해보세요.

2

강지훈님의 프로필

강지훈

2022.01.05

부모에 justifiy-content:center 을 줘야 자식에게 적용되는거 아닌가요??

slow님의 프로필

slow

질문자

2022.01.05

구원자... 감사합니다 ㅠㅠ

0

지훈님께서 잘 답변해주셨네요! 감사합니다 :)