三级标题定位在左边固定位置

盒子模型:通过改变元素的外边距或者内边距来实现元素的移动。

定位:是通过元素的位置移动出现在网页的相对位置中。

<style>
        *{
            padding: 0;
            margin: 0;
        }
        .page{
            width: 100%;
            height: 4043px;
            /*background: url("") center top no-repeat;*/
        }
        .nav{
            width: 160px;
            height: 205px;
            position: fixed;
            left: 0;
            top: 50%;
            margin-top:-103px ;
            font-family: 'Miscrosoft YaHei';
        }
        .nav-li{
            width: 160px;
            height: auto;
            border-bottom: 1px solid #ffffff;
            background: #333;
            text-align: center;
            line-height: 40px;
            color: #ffffff;
            font-size: 16px;
            cursor: pointer;/*指针的形状变成手的形状。表示可点击*/
        }
        .tit{
            width: 160px;
            height: 40px;
        }
        .nav-li ul{
            width: 160px;
            height: auto;
            background: #ffffff;
            display: none;
        }
        .nav-li ul li{
            width: 160px;
            height: 40px;
            border-bottom: 1px dashed #666666;
            color: #333333;
            text-align: center;
            line-height: 40px;
        }
        .nav-li ul li:hover .list-3{
            display: block;
        }
        .nav-li:hover ul{
            display: block;
        }
        .list-3{
            width: 160px;
            height: auto;
            position: absolute;
            left: 160px;
            top: 40px;
            display: none;
        }
        .list-3Dom{
            width: 160px;
            height: 40px;
            background: #444;
            border-bottom: 1px solid #ffffff;
            text-align: center;
            line-height: 40px;
            color: #ffffff;

        }
    </style>

</head>

<body>
<div class="page">
    <div class="nav">
        <div class="nav-li">
            <div class="tit">慕课网的标题</div>
            <ul>
                <li>
                    二级栏目
                    <div class="list-3">
                        <div class="list-3Dom">三级栏目</div>
                        <div class="list-3Dom">三级栏目</div>
                        <div class="list-3Dom">三级栏目</div>
                        <div class="list-3Dom">三级栏目</div>
                        <div class="list-3Dom">三级栏目</div>
                        <div class="list-3Dom">三级栏目</div>
                    </div>

                </li>
                <li>
                    二级栏目
                </li>
                <li>
                    二级栏目
                </li>
            </ul>
        </div>
        <div class="nav-li">慕课网的标题</div>
        <div class="nav-li">慕课网的标题</div>
        <div class="nav-li">慕课网的标题</div>
        <div class="nav-li">慕课网的标题</div>
        <div class="nav-li">慕课网的标题</div>
    </div>
</div>

</body>

猜你喜欢

转载自blog.csdn.net/weixin_40512519/article/details/81355588