定位练习
纯静态页面样式效果
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"><</div>
<div class="right">></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%;
}