实现导航栏下拉菜单(带下拉三级菜单)

目录

效果图 

html+css

Vue2+SCSS

用纯div的方式

方式4:推荐 


效果图 

html+css

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <title></title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body,
        html {
            font-size: 14px;
            font-family: 'Microsoft Yahei', '微软雅黑', 'Simsun', '宋体', 'Arial', sans-serif;
        }

        .head-nav-con {
            width: 100%;
            height: 60px;
            background: #39b97d;
        }

        .head-nav-con ul {
            list-style: none;
            cursor: pointer;
        }

        .head-nav-con ul li {
            width: 170px;
            float: left;
        }

        .head-nav-con ul li:hover {
            background: #ff9c01;
        }

        .head-nav-con ul a {
            display: block;
            text-decoration: none;
            text-align: center;
            line-height: 60px;
            color: white;
        }

        .head-nav-con .drop-down {
            position: relative;
        }

        .head-nav-con .drop-down:hover .drop-down-content {
            display: block;
        }

        .head-nav-con .drop-down-content {
            display: none;
            position: absolute;
            z-index: 1;
            background: #007130;
        }

        .head-nav-con .drop-down-content li:hover {
            background-color: #17c8b9;
        }

        .head-nav-con .drop-down-2 {
            position: relative;
        }

        .head-nav-con .drop-down-2:hover .drop-down-content-2 {
            display: block;
        }

        .head-nav-con .drop-down-content-2 {
            display: none;
            position: absolute;
            left: 170px;
            top: 0;
            z-index: 1;
            background-color: #7b1fbe94;
        }

        .head-nav-con .drop-down-content-2 li {
            float: none;
            margin-bottom: 5px;
            background-color: #da283a;
        }

        .head-nav-con .drop-down-content-2 li:hover {
            background-color: #17c86a;
        }
    </style>
</head>

<body>
    <div class="head-nav-con">
        <ul>
            <li><a>首页</a></li>
            <li><a>一级菜单</a></li>
            <li class="drop-down">
                <a>二级菜单~</a>
                <ul class="drop-down-content">
                    <li><a>二级菜单</a></li>
                    <li><a>二级菜单</a></li>
        
  • 1
    点赞
  • 35
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值