导航的制作

目录

一、导航

二、简单导航


一、导航

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        /*方案一:转化为行级块*/
        /*.menu{
            font-size: 0;
        }
        .menu>li{
            list-style: none;
            display: inline-block;
            border: 1px solid red;
            font-size: 14px;
        }*/
        /*方案二:设置浮动*/
        .bgback{
            position: relative;
            background-color: #000;
        }
        .menu{
            height: 40px;
            padding: 4px 0;
        }
        .nav{
            position: absolute;
            left: 0;
            top: 40px;
            padding: 4px 0;
            height: auto;
            display: none;
            z-index: 1;
        }
        .menu:after,.nav:after,.nav_child:after{
            content: " ";
            position: absolute;
            width: 100%;
            height: 4px;
            left: 0;
            bottom: 0;
            /*border-bottom: 3px solid red;*/
            /*background: linear-gradient(to 
            right,red,green,blue,orangered,deeppink,chocolate,gold);*/
            /*用角度设置*/
            /*background: linear- 
            gradient(0deg,red,green,blue,orangered,deeppink,chocolate,gold);*/
            background: linear- 
            gradient(90deg,red,green,blue,orangered,deeppink,chocolate,gold);
        }
        .menu:before,.nav:before,.nav_child:before{
            content: " ";
            position: absolute;
            width: 100%;
            height: 4px;
            left: 0;
            top: 0;
            /*border-bottom: 3px solid red;*/
            /*background: linear-gradient(to 
             right,red,green,blue,orangered,deeppink,chocolate,gold);*/
            /*background: linear- 
             gradient(0deg,red,green,blue,orangered,deeppink,chocolate,gold);*/
             background: linear- 
             gradient(90deg,red,green,blue,orangered,deeppink,chocolate,gold);
        }
        .menu>li{
            /*设置等宽的导航*/
            /*width: 100px;
            text-align: center;*/
            /*根据内容设置宽度*/
            position: relative;
            padding: 0 50px;
            color: #fff;
            list-style: none;
            float: left;
            height: 40px;
            line-height: 40px;
            text-align: center;
            cursor: pointer;
        }
        .menu>li:hover{
            background-color: white;
            color: black;
        }
        .nav>li{
            list-style: none;
            width: 118px;
            text-align: left;
            padding: 10px;
            position: relative;


        }
        .menu>li:hover>.nav{
            color: white;
        }
        .nav>li:hover{
            background-color: white;
            color: black;
        }
        .nav:after{
            content: " ";
            position: absolute;
            width: 100%;
            height: 4px;
            left: 0;
            bottom: 0;
            background: linear- 
            gradient(90deg,red,green,blue,orangered,deeppink,chocolate,gold);
        }
        .menu>li:hover>.nav{
            display: block;
        }
        .nav_child {
            display: none;
            position: absolute;
            width: 100px;
            right: -100px;
            top: 0px;
        }
        .nav_child > li {
            list-style: none;
            padding: 0 20px 0 10px;
            color: white;
            background-color: black;
        }
        .nav_child > li:hover {
            color: black;
            background-color: white;

        }
        .nav > li:hover > .nav_child {
            color: #fff;
            display: block;
        }
    </style>
</head>
<body>
<ul class="menu bgback">
    <li>首页</li>
    <li>课程
        <ul class="nav bgback">
            <li>html1/css</li>
            <li>html5/css3</li>
            <li>javascript
                <ul class="nav_child">
                    <li>数据库</li>
                    <li>JSP</li>
                    <li>java</li>
                </ul>
            </li>
            <li>vue</li>
        </ul>
    </li>
    <li>社交活动</li>
    <li>联系我们</li>
    <li>论坛</li>
</ul>
</body>
</html>

二、简单导航

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .menu{
            height: 40px;
        }
        .menu>li{
            /*margin-left: -1px;*/
            list-style: none;
            float: left;
            width: 100px;
            height: 40px;
            text-align: center;
            line-height: 40px;
            border: 1px solid black;
            box-sizing: border-box;
            box-shadow: 0 0 1px black;
        }
        .nav>li{
            list-style: none;
            border: 1px solid black;
            box-sizing: border-box;
            height: 40px;
            text-align: center;
            padding-left: 10px;
        }
        .nav{
            display: none;
        }
        .menu>li:hover>.nav{
            display: block;
        }
        .menu>li:hover,.nav>li:hover,.nav_child>li:hover{
            background-color: aliceblue;
        }
        .nav_child{
            margin-left: 87px;
            margin-top: -40px;
            display: none;
        }
        .nav_child>li{
            width: 100px;
            height: 40px;
            list-style: none;
            border: 1px solid black;
            padding-left: -10px;
        }
        .nav>li:hover>.nav_child{
            display: block;
        }
    </style>
</head>
<body>
<ul class="menu">
    <li>动态</li>
    <li>博客</li>
    <li>分类专栏
        <ul class="nav">
            <li>c语言</li>
            <li>java</li>
            <li>JSP</li>
            <li>前端
                <ul class="nav_child">
                    <li>html</li>
                    <li>css</li>
                    <li>javascript</li>
                    <li>vue</li>
                </ul>
            </li>
            <li>数据库</li>
        </ul>
    </li>
    <li>Bink</li>
    <li>更多</li>
</ul>
</body>
</html>

  • 8
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

南初️

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值