前端:定位练习

定位练习

纯静态页面样式效果

1、二级窗口
HTML代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./reset.css">
    <link rel="stylesheet" href="./index.css">
</head>
<body>
    <header class="header">
        <ul class="topnav clearfix">
            <li><a href="">Lorem.</a></li>
            <li><a href="">Alias!</a></li>
            <li><a href="">Veritatis!</a></li>
            <li>
                <a href="">客户服务</a>
                <div class="submenu">
                    <ul class="sa">
                        <li>Lorem.</li>
                        <li>Atque.</li>
                        <li>Tempora?</li>
                    </ul>
                </div>
            </li>
            <li><a href="">Fugiat!</a></li>
        </ul>
    </header>
</body>
</html>

CSS代码

/*解决高度坍塌*/
.clearfix::after{
    content: "";
    display: block;
    clear: both;
}
.header{
    background-color:#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-color: #fff;
    border: 2px solid #ccc;
    border-bottom: none;
    line-height: 36px;


}
.header .topnav>li .submenu{
    /* text-align: center; */
    line-height: 1.5;
    width: 300px;
    /* 隐藏 二级菜单*/
    display: none;
    border: 2px solid #cccccc;
    position: absolute;
    right: -2px;
    background-color: #fff;
}
/*出现二级菜单*/
.header .topnav>li:hover .submenu{
    display: block;
    /* padding: 10px; */
}
.header .topnav>li:hover::after{
    content: "";
    position: absolute;
    width: 100%;
    height: 2px;
    background-color: #fff;
    bottom: 0;
    left: 0;

}
.sa>li{
   float: left;
   margin: 0 20px;
}

2、弹出层
HTML代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./reset.css">
    <link rel="stylesheet" href="./index.css">
</head>
<body>
    <div class="main">
        <img src="./img/douyu.png" alt="">
    </div>
    <!-- 遮罩层 -->
    <div class="model">
        <div class="container">
            <div class="main">Lorem, ipsum dolor sit amet consectetur adipisicing elit. Iure aliquid obcaecati in qui, fuga vitae ex facere. Ipsam quasi beatae laudantium non facilis provident sapiente, commodi voluptas corrupti qui voluptatibus?</div>
            <div class="close">x</div>
        </div>
        <div>
            关闭
        </div>
    </div>
</body>
</html>

CSS代码

.main img{
    width: 100%;
}
.model{
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    background-color:rgba(0, 0,0, 0.4);
}
.model .container{
    width: 404px;
    height: 502px;
    background-color: #ffffff;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    position: absolute;
    box-sizing: border-box;
    border-radius: 1em;
    padding: 10px;
}
.model .container .close{
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: salmon;
    color: #ffffff;
    line-height: 20px;
    text-align: center;
    position: absolute;
    top: -8px;
    right: -8px;
    /* 手指光标 */
    cursor: pointer;
}

3、轮播图
HTML代码

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./reset.css">
    <link rel="stylesheet" href="./index.css">
</head>

<body>
    <div class="banner">
        <div class="imgs">
            <a href=""><img src="./img/1.jpg" alt=""></a>
            <a href=""><img src="./img/2.jpg" alt=""></a>
            <a href=""><img src="./img/3.jpg" alt=""></a>
        </div>
        <div class="left">&lt;</div>
        <div class="right">&gt;</div>
        <div class="model">
            <div class="title"><h2>黄河三峡</h2></div>
            <div class="dots">
                <ul>
                    <li></li>
                    <li></li>
                    <li></li>
                </ul>
            </div>
        </div>
    </div>
</body>

</html>

CSS代码

.banner{
    width: 520px;
    height: 304px;
    
    margin: 1em auto;
    overflow: hidden;
    position: relative;
}
.banner .imgs{
    width: 1560px;
    height: 304px;

}
.banner .imgs img{
    width: 520px;
    height: 304px;
}
.banner .imgs a{
    float: left;
}
.banner .left,.banner .right{
    position: absolute;
    width: 50px;
    height: 50px;
    color: #ffffff;
    border-radius: 50%;
    top:0;
    bottom: 0;
    margin: auto;
    text-align: center;
    font-size: 25px;
    line-height: 50px;
    font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
    cursor: pointer;
}
.banner .left{
    left:30px;
}
.banner .right{
    right: 30px;
}
.banner .left:hover,.banner .right:hover{
    color: red;
    background-color: #ffffff;
}
.banner .model{
    position: absolute;
    width: 100%;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.5);
    left: 0;
    bottom: 0;
    color: #ffffff;
    line-height: 40px;
    padding:0 20px;
    box-sizing: border-box;
}
.banner .model .title{
    float: left;
    
}
.banner .model .dots{
    float: right;
}
.banner .model .dots li{
    width: 8px;
    height: 8px;
    background-color:#ccc;
    display: inline-block;
    margin: 0 2px;
    border-radius: 50%;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值