• css的position属性


     

     

     

     

    fixed属性使该元素定位不受父元素定位的影响。

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>position</title>
        <style>
            *{
                padding: 0;
                margin: 0;
            }
            .page{
                width: 100%;
                height: 4043px;
                background: url("mooc.png") 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 #FFF;
                background: #333;
                text-align: center;
                line-height: 40px;
                color: #FFF;
                font-size: 16px;
                cursor: pointer;
            }
            
            .tit{
                width: 160px;
                height: 40px;
            }
            
            .nav-li:hover ul{
                display: block;
            }
            
            .nav-li ul{
                width: 160px;
                height: auto;
                background: #FFF;
                display: none;
            }
            
            .nav-li ul li{
                width: 160px;
                height: 40px;
                border-bottom: 1px dashed #666;
                color: #333;
                text-align: center;
                line-height: 40px;
                position: relative;
            }
            
            .nav-li ul li:hover .list-3{
                display: block;
            }
            
            .list-3{
                width: 160px;
                height: auto;
                position: absolute;
                left: 160px;
                top: 0px;
                display: none;
            }
            
            .list-3Dom{
                width: 160px;
                height: 40px;
                background: #444;
                border-bottom: 1px solid #FFF;
                text-align: center;
                line-height: 40px;
                color: #FFF;
            }
            
        </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>
                         </li>
                         <li>
                             二级栏目
                             <div class="list-3">
                                 <div class="list-3Dom">三级栏目</div>
                                 <div class="list-3Dom">三级栏目</div>
                                 <div class="list-3Dom">三级栏目</div>                                                          
                             </div>
                         </li>
                         <li>
                             二级栏目
                             <div class="list-3">
                                 <div class="list-3Dom">三级栏目</div>
                                 <div class="list-3Dom">三级栏目</div>
                                 <div class="list-3Dom">三级栏目</div>                                                          
                             </div>
                         </li>                                 
                     </ul>     
                </div>
                <div class="nav-li">
                     <div class="tit">慕课网的标题</div>
                     <ul>
                         <li>
                             二级栏目
                         </li>
                         <li>
                             二级栏目
                         </li>
                         <li>
                             二级栏目
                         </li>                                  
                     </ul>     
                </div>
                <div class="nav-li">
                     <div class="tit">慕课网的标题</div>
                     <ul>
                         <li>
                             二级栏目
                         </li>
                         <li>
                             二级栏目
                         </li>
                         <li>
                             二级栏目
                         </li>                                  
                     </ul>     
                </div>
                <div class="nav-li">
                     <div class="tit">慕课网的标题</div>
                     <ul>
                         <li>
                             二级栏目
                         </li>
                         <li>
                             二级栏目
                         </li>
                         <li>
                             二级栏目
                         </li>                                  
                     </ul>     
                </div>
                <div class="nav-li">
                     <div class="tit">慕课网的标题</div>
                     <ul>
                         <li>
                             二级栏目
                         </li>
                         <li>
                             二级栏目
                         </li>
                         <li>
                             二级栏目
                         </li>                                  
                     </ul>     
                </div>                                    
            </div>
        </div>
     
    </body>
    </html>
  • 相关阅读:
    【win10】浏览器Chrome 和edge 体验对比与使用心得
    【Java】 VM 环境配置过程要点( win10,64位)
    office2013 激活方法
    产品激活 比如Windows激活 , office激活 等激活的原理是什么? KMS等激活工具安全吗?
    回顾外滩踩踏事件,吸取的教训
    【win7】Ubuntu安装使用中的一些注意事项
    黑屏
    mock测试(一)
    Django模型类(一)
    获取本机局域网ip和出口ip
  • 原文地址:https://www.cnblogs.com/zengyu1234/p/15732862.html
Copyright © 2020-2023  润新知