• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 HTML/CSS 게시판 이미지 상하 가운데 정렬이 안됩니다 ㅠㅠ

이미지 상하 가운데 정렬이 안됩니다 ㅠㅠ

2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 글쓴이
  • #107509

    김태완
    참가자
    레이아웃2 숙제하던중에 저는 좀 복잡하게 한번 도전하고 싶어서 하던 예제에서 content부분에서 하고 있었습니다.
    
    하다가 inline-block으로 하다가 가운데 정렬이 생겨서 float를 사용하여 만들었습니다.
    그러다가 이제 이미지 섹션만들었으니 이미지 넣어서 가운데 정렬해보자 해서 하는데 잘 안됩니다 ㅠㅠ
    
    처음에는 margin : auto auto auto auto; 이렇게 했는데 잘 안되더군요 ㅠㅠ...
    
    참고 코드 남깁니다 ....문제점
    html 
    ```
    </pre>
    <pre><!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title>Document</title>
            <link href="css/index.css" rel="stylesheet">
        </head>
        <body></pre>
    <pre>        <div class="container">
                <div class="header"></pre>
    <pre>            </div></pre>
    <pre>            <div class="left-menu"></div><!--  </pre>
    <pre>         --><div class="content">
                    <div class="view">
                        <div class="profile-section"></div>
                        <div class="image">
                            < img src="src/apple.jpg" class="image-card">
                        </div>
                    </div>
                </div>
                <div class="footer"></pre>
    <pre>            </div>
            </div></pre>
    <pre>    </body>
    </html>
    ```
    css
    
    ```
    </pre>
    <pre>.profile {width: 15vw; 
        margin-left: auto; 
        margin-right: auto; 
        display: block; 
        margin-top: 2vw; 
        margin-bottom: -2vw;
    }</pre>
    <pre>.title {
        font-size: 3vw; 
        font-family: 'gulim'; 
        color:#000000; 
        letter-spacing: 0.02vw; 
        text-align: center; 
        margin-bottom: -1.2vw;
    }</pre>
    <pre>.subtitle{
        text-align: center; 
        font-size: 1.6vw; 
        letter-spacing: 0.05vw;
    }</pre>
    <pre>.box{
        width: 30%;
        height: auto;
        background-color: aqua;
        margin-left: auto;
        margin-right: auto;
        display: block;
        padding: 30px 50px;
        border-radius:  15px;
        font-size: 1vw;
        box-shadow: 5px 5px;
    }</pre>
    <pre>.container{
        width: 800px;
    }</pre>
    <pre>.header{
        width: 100%;
        height: 50px;
        background-color: aquamarine;
    }</pre>
    <pre>.left-menu{
        width: 20%;
        height: 400px;
        background-color: cornflowerblue;
        display: inline-block;
        vertical-align: top;
        /* float: left; */
    }</pre>
    <pre>.content{
        width: 80%;
        height: 400px;
        background-color: coral;
        display: inline-block;
        vertical-align: top;
        /* float: right; */
    }</pre>
    <pre>.footer{
        width: 100%;
        height: 100px;
        background-color: grey;
        /* clear: both; */
    }</pre>
    <pre>.view{
        width: 97%;
        height: 150px;
        background-color: white;
        margin: 9.6px auto 5px auto;
        display: block;
    }</pre>
    <pre>.profile-section{
        width: 79.5%;
        height: 98%;
        background-color: whitesmoke;
        margin: auto ;
        float: left;
    }</pre>
    <pre>.image{
        width: 19.5%;
        height: 98%;
        background-color: whitesmoke;
        margin: auto ;
        float: right;
    }</pre>
    <pre>.image-card{
        width: 95%;
        height: auto;
        margin-top: auto;
        margin-bottom: auto;
        margin-left: auto;
        margin-right: auto;
        display: block;
    }
    ```
    #107528

    codingapple
    키 마스터
    원래 상하정렬은 잘 안됩니다 
    부모에 display : flex 주고 이미지에 align-items : center 줘야합니다
2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠