下拉菜单

<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        ul{
            list-style: none;
        }
        .nav>li{
            float: left;
        }
        ul a{
            display: block;
            text-decoration: none;
            width: 100px;
            height: 50px;
            text-align: center;
            line-height: 50px;
            color: white;
            background-color: #2f3e45;
        }
        .nav>li:first-child a{
            border-radius: 10px 0 0 10px;
        }
        .nav>li:last-child a{
            border-radius: 0 10px 10px 0;
        }
        .drop-down{
            /*position: relative;*/
        }
        .drop-down-content{
            padding: 0;
            display: none;
            /*position: absolute;*/
        }
        
        h3{
            font-size: 30px;
            clear: both;
        }
        .drop-down-content li:hover a{
            background-color:red;
        }
        .nav .drop-down:hover .drop-down-content{
            display: block;
        }
</style>
</head>
<body>
    <ul class="nav">
        <li><a href="#">下拉菜单</a></li>
        <li class="drop-down"><a href="#">下拉菜单</a>
            <ul class="drop-down-content">
                <li><a href="#">我是1</a></li>
                <li><a href="#">我是2</a></li>
                <li><a href="#">我是3</a></li>
            </ul>
            </li>
        <li><a href="#">下拉菜单</a></li>
        <li><a href="#">下拉菜单</a></li>
        <li><a href="#">下拉菜单</a></li>
    </ul>
    <h3>我是测试文字</h3>
</body>

</html>

下拉菜单

<style>
        ul{
            list-style: none;
        }
        .nav>li{
            float: left;
        }
        ul a{
            display: block;
            text-decoration: none;
            width: 100px;
            height: 50px;
            text-align: center;
            line-height: 50px;
            color: white;
            background-color: #2f3e45;
        }
        .nav>li:first-child a{
            border-radius: 10px 0 0 10px;
        }
        .nav>li:last-child a{
            border-radius: 0 10px 10px 0;
        }
        .drop-down{
            /*position: relative;*/
            height: 50px;
            overflow: hidden;
        }
        .drop-down-content{
            padding: 0;
            /*position: absolute;*/
        }
        
        h3{
            font-size: 30px;
            clear: both;
/*            position: relative;
            z-index: -1;*/
        }
        .drop-down-content li:hover a{
            background-color:red;
        }
        .nav .drop-down:hover{
            overflow: visible;
        }

</style>

下拉菜单

<style>

        ul{
            list-style: none;
        }
        .nav>li{
            float: left;
        }
        ul a{
            display: block;
            text-decoration: none;
            width: 100px;
            height: 50px;
            text-align: center;
            line-height: 50px;
            color: white;
            background-color: #2f3e45;
        }
        .nav>li:first-child a{
            border-radius: 10px 0 0 10px;
        }
        .nav>li:last-child a{
            border-radius: 0 10px 10px 0;
        }
        .drop-down{
            /*position: relative;*/
            height: 50px;
        }
        .drop-down-content{
            padding: 0;
            opacity: 0.3;
            height: 0;
            overflow: hidden;
            transition: all 1s ease;
            /*position: absolute;*/
        }
        
        h3{
            font-size: 30px;
            clear: both;
/*            position: relative;
            z-index: -1;*/
        }
        .drop-down-content li:hover a{
            background-color:red;
        }
        .nav .drop-down:hover .drop-down-content{
            opacity: 1;
            height: 150px;
        }

相关文章:

  • 2021-11-28
  • 2021-11-07
  • 2021-11-07
  • 2021-11-07
  • 2021-12-12
  • 2021-09-17
  • 2021-10-19
猜你喜欢
  • 2021-02-28
  • 2021-11-05
  • 2021-10-19
  • 2021-12-22
  • 2021-12-22
  • 2021-10-29
相关资源
相似解决方案