CSS:二级菜单

12 篇文章 1 订阅

CSS:二级菜单

html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/二级菜单.css">
</head>
<body>
    <header class="header">
        <ul class="topnav clearfix">
            <li><a href="">Lorem.</a></li>
            <li><a href="">Repellat!</a></li>
            <li><a href="">Necessitatibus?</a></li>
            <li>
                <a href="">客户服务</a>
                <div class="submenu">
                   
                    <ul>
                        <li>Lorem.</li>
                        <li>Dolore.</li>
                        <li>Sed.</li>
                        <li>Excepturi.</li>
                        <li>Inventore.</li>
                        <li>Expedita.</li>
                        <li>Sunt.</li>
                        <li>At.</li>
                        <li>Nisi.</li>
                        <li>Tempore!</li>
                    </ul>
                </div>
            </li>
            <li><a href="">At.</a></li>
        </ul>
    </header>

    <div style=" background:lightblue;">
    </div>
</body>
</html>

css:

.clearfix::after {
    content: "";
    display: block;
    clear: both;
}

.header {
    background: #e3e4e5;
    color: #999;
    height: 40px;
    line-height: 40px;
    position: fixed;
    width: 100%;
    left: 0;
    top: 0;
}

.header .topnav>li {
    float: left;
    margin: 0 20px;
    width: 150px;
    text-align: center;
    height: 40px;
    box-sizing: border-box;
    position: relative;
}

.header .topnav>li:hover{
    background: #fff;
    border: 2px solid #ccc;
    border-bottom: none;
    line-height: 36px;
    background: #fff;
}

.header .topnav>li .submenu{
    text-align: left;
    line-height: 1.5;
    width: 300px;
    /* 不生成盒子 */
    display: none; 
    border: 2px solid #ccc;
    box-sizing: border-box;
    position: absolute;
    right: -2px;
    background: #fff;
}

.header .topnav>li:hover .submenu{
    display: block;
    padding: 10px;
}

.header .topnav>li:hover::after{
    content: "";
    position: absolute;
    width: 100%;
    height: 5px;
    background: red;
    bottom: 0;
    left: 0;
    background: #fff;
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值