TIL(today I learned)

2020.11.09 #TIL

노랑세희 2020. 11. 10. 09:09

 학원에서 마우스 오버시 전체가 내려오는 2단 메뉴 만드는 법을 배웠다 새롭게 알게된 점은 2단계 위에 있는 부모에 position: relative를 주면 2단계 하위의 자손 width가 relative를 따라간다는 것이다. 그리고 서브메뉴가 내려올때 배경 100%는 동일한 배경색의 shadow 박스를 만들어서 ul과 함께 내려오게끔 하면 된다. 어제 2단 메뉴로 동부센트레빌과 경기콘텐츠진흥원의 메뉴 부분을 만들었다.

 

 

1. 경기콘텐츠진흥원

HTML

<!doctype html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>경기콘텐츠진흥원</title>

    <link rel="stylesheet" href="css/style.css">

</head>

<body>

    <header>

        <div class="header_in">

            <div class="lnb cf">

                <button class="system">조직도</button>

                <button class="sign">회원가입</button>

                <button class="login">로그인</button>

            </div>

            <h1 class="logo"></h1>

            <div class="gnb">

                <ul>

                    <li>

                        <a href="#">주요사업</a>

                        <ul>

                            <li>

                                <a href="#">경기문화창조허브</a>

                            </li>

                            <li>

                                <a href="#">게임산업</a>

                            </li>

                            <li>

                                <a href="#">음악산업</a>

                            </li>

                            <li>

                                <a href="#">영상산업</a>

                            </li>

                            <li>

                                <a href="#">출판산업</a>

                            </li>

                            <li>

                                <a href="#">경기도 동네서점 상품권</a>

                            </li>

                            <li>

                                <a href="#">빅데이터산업</a>

                            </li>

                            <li>

                                <a href="#">전문인력양성</a>

                            </li>

                            <li>

                                <a href="#">자금지원</a>

                            </li>

                            <li>

                                <a href="#">수출지원</a>

                            </li>

                        </ul>

                    </li>

                    <li>

                        <a href="#">시설이용</a>

                        <ul>

                            <li>

                                <a href="#">프로그램</a>

                            </li>

                            <li>

                                <a href="#">공간</a>

                            </li>

                            <li>

                                <a href="#">장비</a>

                            </li>

                        </ul>

                    </li>

                    <li>

                        <a href="#">기관뉴스</a>

                        <ul>

                            <li>

                                <a href="#">프레스센터</a>

                            </li>

                            <li>

                                <a href="#">소통</a>

                            </li>

                        </ul>

                    </li>

                    <li>

                        <a href="#">알림마당</a>

                        <ul>

                            <li>

                                <a href="#">공지사항</a>

                            </li>

                            <li>

                                <a href="#">사업공고</a>

                            </li>

                            <li>

                                <a href="#">입찰공고</a>

                            </li>

                            <li>

                                <a href="#">결과발표</a>

                            </li>

                            <li>

                                <a href="#">월별 행사 캘린더</a>

                            </li>

                            <li>

                                <a href="#">교육 및 행사</a>

                            </li>

                            <li>

                                <a href="#">타기관 공고</a>

                            </li>

                            <li>

                                <a href="#">정책리포트</a>

                            </li>

                        </ul>

                    </li>

                    <li>

                        <a href="#">GCA소개</a>

                        <ul>

                            <li>

                                <a href="#">인사말</a>

                            </li>

                            <li>

                                <a href="#">일반현황</a>

                            </li>

                            <li>

                                <a href="#">채용정보</a>

                            </li>

                            <li>

                                <a href="#">경영공시</a>

                            </li>

                            <li>

                                <a href="#">윤리경영</a>

                            </li>

                            <li>

                                <a href="#">고객만족경영</a>

                            </li>

                            <li>

                                <a href="#">행정정보공개</a>

                            </li>

                            <li>

                                <a href="#">기부금</a>

                            </li>

                            <li>

                                <a href="#">CI/BI</a>

                            </li>

                            <li>

                                <a href="#">오시는길</a>

                            </li>

                        </ul>

                    </li>

                </ul>

                <div class="gnb_shadow"></div>

            </div>

        </div>

    </header>

</body>

</html>

CSS

*{

    margin0;

    padding0;

}

ul{

    list-stylenone;

}

a{

    text-decorationnone;

    color#666;

}

.cf:after{

    content'';

    displayblock;

    clearboth;

}



header{

    width100%;

    height100%;

    positionrelative;

}

.header_in{

    width1000px;

    height110px;

    margin0 auto;

    background#fff;

}

 

header .lnb{

    width1000px;

    padding30px 10px 0 0;

    box-sizingborder-box;

}

header .lnb button{

    displayblock;

    width97px;

    height32px;

    outlinenone;

    border1px solid #ddd;

    border-radius20px;

    background#fff;

    font-size13px;

    font-weightbold;

    color#666;

    cursorpointer;

}

header .lnb .system{

    floatleft;

    margin-left10px;

}

header .lnb .login,

header .lnb .sign{

    floatright;

    margin-left10px;

}



header .logo{

    width230px;

    height60px;

    backgroundurl(../img/logo.gifno-repeat 50% 50%;

    positionabsoluteleft50%top50%;

    transformtranslate(-50%,-50%);

}




header .gnb{

    width100%;

    positionabsoluteleft0top110px;

    border-bottom1px solid #ddd;

}

 

header .gnbul:before{

    content'';

    displayblock;

    width50px;

    height:50px;

    backgroundurl(../img/ham.pngno-repeat center;

    positionabsoluteleft-50pxtop0;

    cursorpointer;

}

header .gnbul:after{

    content'';

    displayblock;

    width50px;

    height:50px;

    backgroundurl(../img/times.pngno-repeat center;

    positionabsoluteright-100pxtop0;

    cursorpointer;

}

 

header .gnb > ul{

    width1000px;

    height70px;

    margin0 auto;

    positionrelative;

    z-index10;

    background#ddd;

}

header .gnb > ul > li{

    floatleft;

}

 

header .gnb ul li a{

    displayblock;

    width200px;

}

header .gnb > ul > li > a{

    height70px;

    line-height70px;

    text-aligncenter

    font-size18px;

    font-weightbold;

    background#fff;

}

 

header .gnb ul li ul{

    width200px;

    positionabsolute;

    height0;

    overflowhidden;

    transition: height .5sbackground 0.3s;

    border-left1px solid #eee;

}

header .gnb ul li:last-child ul{

    border-right1px solid #eee;

}

header .gnb ul:hover ul{

    height450px;

}

header .gnb ul li ul:hover{

    background#fcf6ff;

}

 

header .gnb ul ul li a{

    height20px;

    line-height20px;

    padding20px 0 0 25px;

    text-alignleft;

    font-size14px;

}

header .gnb ul ul li:hover a{

    font-weightbold;

}






header .gnb .gnb_shadow{

    positionabsolutetop71pxleft0;

    width100%;

    height0;

    background#ddd;

    transitionall .5s;

}

header .gnb > ul:hover + .gnb_shadow{

    height450px;

    border-top1px solid #eee;

}

결과

 

 

 

2. 동부센트레빌

HTML

<!doctype html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>동부센트레빌</title>

    <link rel="stylesheet" href="css/style.css">

    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@100;300;400;500;700;900&display=swap" rel="stylesheet">

</head>

<body>

    <header>

        <div class="header_in cf">

            <h1 class="logo">

                <a href="#">

                    <img src="img/top_logo.png" alt="동부센트레빌">

                </a>

            </h1>

            <div class="lnb">

                <a href="#" class="login">LOGIN</a>

                <a href="#" class="join">JOIN</a>

            </div>

            <div class="gnb">

                <ul>

                    <li>

                        <a href="#">분양안내</a>

                        <ul>

                            <li><a href="#">분양캘린더</a></li>

                            <li><a href="#">분양정보</a></li>

                        </ul>

                    </li>

                    <li>

                        <a href="#">현장안내</a>

                        <ul>

                            <li><a href="#">공사단지 정보</a></li>

                            <li><a href="#">입주단지 정보</a></li>

                        </ul>

                    </li>

                    <li>

                        <a href="#">입주안내</a>

                        <ul>

                            <li><a href="#">입주가이드</a></li>

                            <li><a href="#">중도금납부조회</a></li>

                            <li><a href="#">입주예약</a></li>

                        </ul>

                    </li>

                    <li>

                        <a href="#">고객서비스</a>

                        <ul>

                            <li><a href="#">A/S센터</a></li>

                            <li><a href="#">고객문의</a></li>

                        </ul>

                    </li>

                    <li>

                        <a href="#">브랜드</a>

                        <ul>

                            <li><a href="#">센트레빌</a></li>

                            <li><a href="#">센트레빌 아스테리움</a></li>

                            <li><a href="#">단지갤러리</a></li>

                            <li><a href="#">수상실적</a></li>

                            <li><a href="#">센트레빌 소식</a></li>

                        </ul>

                    </li>

                </ul>

                <div class="gnb_shadow"></div>

            </div>

        </div>

    </header>

</body>

</html>

 

CSS

*{

    margin0;

    padding0;

    font-family'Noto Sans KR'sans-serif;

}

ul{

    list-stylenone;

}

a{

    text-decorationnone;

    color#000;

}

.cf:after{

    content'';

    displayblock;

    clearboth;

}

header{

    width100%;

    positionrelative;

}

.header_in{

    margin0 auto;

    height700px;

    max-width1920px;

    min-width1260px;

    backgroundurl(../img/visualimg_1_1920.jpgno-repeat center;

}

 

header .logo{

    floatleft;

    width170px;

    height70px;

    positionrelative;

    z-index100;

header .logo img{

    displayblock;

}

 

header .lnb{

    floatright;

}

.lnb a{

    positionrelative;

    z-index10;

    displayblock;

    padding-left18px;

    width100px;

    height70px;

    line-height70px;

    text-aligncenter;

    color#333;

    font-size12px;

    background#eee;

    floatleft;

    box-sizingborder-box;

}

.lnb a:hover{

    color#042e6f;

}

.lnb a:before{

    content'';

    displayblock;

    width22px;

    height22px;

    transformtranslateY(-50%);

}

.lnb a:nth-child(1):before{

    backgroundurl(../img/icon.pngno-repeat 0 0;

    positionabsoluteleft14pxtop50%;

}

.lnb a:nth-child(2):before{

    backgroundurl(../img/icon.pngno-repeat -23px 0;

    positionabsoluteleft18pxtop50%;

}

 

header .gnb{

    width100%;

    positionrelative;

}

header .gnb > ul{

    positionrelative;

    z-index10;

    width800px;

    height70px;

    margin0 auto;

    border-bottom0.5px solid #eee;

}

header .gnb > ul:hover{

    border-bottomnone;

}



header .gnb > ul > li{

    floatleft;

}

 

header .gnb > ul > li > a{

    displayblock;

    width160px;

    height70px;

    line-height70px;

    text-aligncenter;

    font-size18px;

    color#fff;

    font-weightbold;

    positionrelative;

}

header .gnb > ul > li > a:after{

    content'';

    displayblock;

    width100%;

    height2px;

    background#fff;

    positionabsoluteleft0bottom0;

    transformscaleX(0);

    transition: transform .4s;

}

header .gnb > ul > li:hover > a:after{

    transformscaleX(1);

}

 

header .gnb ul li ul{

    padding30px 0 0;

    height0;

    overflowhidden;

    opacity0;

    visibilityhidden;

    transitionall .3s;

}

header .gnb ul:hover li ul{

    height300px;

    opacity1;

    visibilityvisible;

}

 

header .gnb ul ul li a{

    displayblock;

    width160px;

    line-height38px;

    color#fff;

    text-aligncenter;

}





header .gnb .gnb_shadow{

    positionabsolutetop0left0;

    width100%;

    height0;

    background#1f2572;

    transitionall .4s;

    z-index9;

}

header .gnb ul:hover + .gnb_shadow{

    height330px;

}

 

결과