定位练习

二级菜单

<div class="top">
    <ul class="topnav clearfix">
        <li>主站</li>
        <li>番剧</li>
        <li class="login">
            <a href="#">登录</a>
            <div class="submenu">Lorem ipsum dolor sit, amet consectetur adipisicing elit. Dignissimos, rerum?</div>
        </li>
        <li>收藏</li>
    </ul>
</div>
.clearfix::after{  /*清除浮动*/
    content: "";
    display: block;
    clear: both;
}
.top{
    width: 100%;
    height: 40px;
    line-height: 40px;
    background-color: lightskyblue;
    /* color: #999; */
    position: fixed;
    top: 0;
    left: 0;
}
.top .topnav>li{
    float: left;
    width: 250px;
    height: 40px;
    text-align: center;
    font-size: 15px;
    font-weight: bold;
    color: black;
    margin: 0 20px;
    /* padding: 0 8px; */
    /* background-color: #fff; */
    box-sizing: border-box;
    position: relative;
}
.top .topnav>li:hover{
    background-color: #fff;
    border: 2px solid #ccc;
    border-bottom: none;
    line-height: 36px;
}

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

.top .topnav>li:hover .submenu{
    display: block;
}

.top .topnav>li:hover::after{
    content: "";
    position: absolute;
    width: 100%;
    height: 5px;
    bottom: 0;
    left: 0;
    background: #fff;
}

效果如下:

定位练习

弹出层

<div class="main">
    <img src="img/douyu.png" alt="">
    <div class="modal">
        <div class="container">
            Lorem ipsum dolor, sit amet consectetur adipisicing elit. Necessitatibus cum suscipit consectetur at! Magni et consequuntur impedit fugit ab quaerat obcaecati aspernatur quod. Voluptatum animi eveniet quo rem dicta. Beatae.
            <div class="close">X</div>
        </div>
        
    </div>
</div>
.main img{
    width: 100%;
}

.main .modal{
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: rgba(0,0,0,0.5);
}

.modal .container{
    width: 200px;
    height: 300px;
    background-color: lightblue;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    box-sizing: border-box;
    padding: 10px;
}
.close{
    width: 20px;
    height: 20px;
    border-radius: 50%;
    color: black;
    background-color: #eee;
    text-align: center;
    line-height: 20px;
    position: absolute;
    top: -10px;
    right: -10px;
    cursor: pointer;
}

效果如下:
定位练习

轮播图

    <div class="banner">
        <div class="imgs">
            <a href=""><img src="img/img_1.jpg" alt=""></a>
            <a href=""><img src="img/img_2.jpg" alt=""></a>
            <a href=""><img src="img/img_3.jpg" alt=""></a>
        </div>
        <div class="left">&lt;</div>
        <div class="right">&gt;</div>
        <div class="modal">
            <div class="content">Lorem ipsum dolor sit.</div>
            <div class="dots">
                <ul>
                    <li></li>
                    <li></li>
                    <li></li>
                    <li></li>
                </ul>
            </div>
        </div>
    </div>
.banner{
    width: 520px;
    height: 304px;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
}
.banner .imgs{
    width: 1560px;    
}
.banner .imgs img{
    width: 520px;
    height: 304px;

}
.banner .imgs a{
    float: left;
}
.banner .left,
.banner .right{
    position: absolute;
    width: 50px;
    height: 50px;
    top: 0;
    bottom: 0;
    margin: auto ;
    font-size: 3em;
    text-align: center;
    font-family: Arial;
    color: #fff;
    border-radius: 50%;
    line-height: 50px;
    cursor: pointer;
}
.banner .left:hover,
.banner .right:hover{
    background-color: #fff;
    color: rosybrown;
}
.banner .left{
    left: 20px;
}
.banner .right{
    right: 20px;
}
.banner .modal{
    width: 520px;
    height: 40px;
    background: rgba(0,0,0,0.3);
    position: absolute;
    left: 0;
    bottom: 0;
    line-height: 40px;
    color: #fff;
    box-sizing: border-box;
    padding: 0 20px ;
}

.banner .modal .content{
    float: left;
    font-size: 1.5em;
    text-align: center;
}
.banner .modal .dots{
    float: right;
}
.banner .modal .dots li{
    width: 8px;
    height: 8px;
    display: inline-block;
    margin: 0 2px;
    background-color: #369;
    border-radius: 50%;
    cursor: pointer;
}
.banner .modal .dots li:hover{
    background-color: #fff;
}

效果如下:
定位练习

上一篇:微信小程序项目实战(三)首页Banner的编写以及微信网络请求讲解


下一篇:2020 BIT冬训-图&&DFS&&BFS A - Fixing Banners Gym - 102394F