Language

UIUX/내용

메뉴바

초코렛맛 2024. 4. 18. 23:18

 

    <nav class="menu">
        <ul>
            <li>
                <a href="#">1메뉴 1</a>
                <ul>
                    <li><a href="">2메뉴 1</a></li>
                    <li><a href="">2메뉴 2</a></li>
                    <li><a href="">2메뉴 3</a></li>                    
                </ul>
            </li>
            <li>
                <a href="#">1메뉴 2</a>
                <ul>
                    <li><a href="">2메뉴 1</a></li>
                    <li><a href="">2메뉴 2</a></li>
                    <li><a href="">2메뉴 3</a></li>                    
                </ul>
            </li>
            <li>
                <a href="#">1메뉴 3</a>
                <ul>
                    <li><a href="">2메뉴 1</a></li>
                    <li><a href="">2메뉴 2</a></li>
                    <li><a href="">2메뉴 3</a></li>  
                </ul>
            </li>

        </ul>
    </nav>
a{
    text-decoration: none;
    color: inherit;
}
li{
    width: 100px;
    background-color: beige;
}
.menu{
    text-align: center;
}
ul{
    list-style: none;
    padding: 0;
    margin: 0;
}
.menu> ul>li{
    position: relative;
    display: block;    
}
.menu > ul > li > ul{
    position: absolute;
    display: none;
}

.menu> ul>li:hover > ul{
    display: inline-block;
    /* display: block; */
}
a{
    text-decoration: none;
    color: inherit;
}
li{
    width: 100px;
    height: 50px;
    background-color: beige;
    align-content: center;
}
.menu{
    text-align: center;  
}
ul{
    list-style: none;
    padding: 0;
    margin: 0;
}
.menu> ul>li{
    position: relative;
    display: block;
    
}
.menu > ul > li > ul{
    position: absolute;
    display: none;
    left: 100%;
    top: 0;
}

.menu> ul>li:hover > ul{
    display: inline-block;
    /* display: block; */
}

 

 

<style>
    .wrap{
        height: 600px;
        width: 80%;
        margin: 0 auto;
        border: 1px solid #000;
    }
    nav{
        height: 200px;
        background-color: aqua;
        align-content: end;
        position: relative;
    }
    main{
        height: 400px;
        background-color: red;
        position: relative;
        z-index: -2;
    }
    a{
        color: inherit;
        text-decoration: none;
    }
    ul{
        padding: 0;
        list-style: none;
        margin: 0;
    }
    .menu{
        width: 300px;
        height: 40px;
        background-color: blue;
        display: flex;
        margin-left: auto;
    }
    .menu > li{
        width: calc(100% / 3);
        
        
    }
    .menu > li a{
        width: 100%;
        height: 40px;
        align-content: center;
        text-align: center;
        display: inline-block;
        background-color: #fff;            
    }
    .submenu{
        display: none;
    }
    .menu > .o{
        
        height: 200px;
        background-color: blue;
        position: absolute;
        z-index: -1;
        width: 100%;
        left: 0;
        top: 100%;
        display: none;
    }
    .menu:hover .submenu, .menu:hover  .o{
        display: block;
    }
</style>

<body>
    <div class="wrap">
        <nav>
            <ul class="menu">
                <li><a href="">메뉴1</a>
                    <ul class="submenu">
                        <li><a href="">세부1</a></li>
                        <li><a href="">세부2</a></li>
                        <li><a href="">세부3</a></li>
                    </ul>
                </li>
                <li><a href="">메뉴1</a>
                    <ul class="submenu">
                        <li><a href="">세부1</a></li>
                        <li><a href="">세부2</a></li>
                        <li><a href="">세부3</a></li>
                    </ul>
                </li>
                <li><a href="">메뉴1</a>
                    <ul class="submenu">
                        <li><a href="">세부1</a></li>
                        <li><a href="">세부2</a></li>
                        <li><a href="">세부3</a></li>
                    </ul>
                </li>
                <div class="o"></div>
            </ul>
        </nav>
        <main></main>
    </div>

</body>

'UIUX > 내용' 카테고리의 다른 글

이미지 트렌지션  (1) 2024.05.01
2번째 결과 형식  (0) 2024.04.25
position 속성  (0) 2024.04.17
display 속성  (1) 2024.04.17
box모델  (0) 2024.04.17