ent="">
<style>
*{
margin: 0;
padding: 0;
}
.header {
height: 50px;
background: rgba(0,0,0,0.80);
}
.nav {
width: 980px;
height: 50px;
margin: 0 auto;
color: #fff;
}
.content{
width: 980px;
height: 425px;
margin-right: auto;
margin-left: auto;
overflow: hidden;
border-bottom: 1px solid black ;
}
.left {
width: 645px;
height: 425px;
background-color: yellow;
float: left;
}
.right {
width: 310px;
height: 425px;
background-color: pink;
float: right;
}
.wrap980{
width: 980px;
margin: 0 auto;
height: 200px;
background-color: green;
}
body{
min-width: 980px;
}
</style>
</head>
<body>
<div class="header">
<div class="nav">This is NAV</div>
</div>
<div class="main">
<div class="content">
<div class="left"></div>
<div class="right"></div>
</div>
</div>
<div class="footer">
<div class="wrap980"></div>
</div>
</body>
</html>
11. 定位
1> relative相对定位
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Examples</title>
<meta name="description" content="">
<meta name="keywords" content="">
<style>
*{
margin: 0;
padding: 0;
}
.box1 {
width: 150px;
height: 150px;
background: black;
}
.box2 {
width: 50px;
height: 50px;
background-color: red;
position: relative;
}
</style>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
<div class="box1"></div>
</body>
</html>
- 随心所欲将元素摆放任意位置,并且不影响别的元素的位置。
- 只要用了定位,且值不为static时,都拥有四个样式:top、left、bottom、right,来调整元素的位置,
- 移动后元素仍然占据原来的位置
- 相对与元素父类元素定位进行平移
2> absolute绝对定位
- 不占据任何空间,比浮动飘得还要高
- 会覆盖浮动,但不会像浮动一样从左到右排列,而是发生重叠现象
- 相对于该元素的父类元素的非static定位进行移动,若父类元素没有专门定位,则向上参考父类的父类的非static定位。。。
3> fixed固定定位
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>fix定位之右下角按钮固定</title>
<meta name="description" content="">
<meta name="keywords" content="">
<style>
* {
margin: 0;
padding: 0;
}
.right {
width: 560px;
height: 400px;
background: pink;
float: left;
}
.left {
width: 250px;
height: 400px;
background: green;
float: right;
}
.warp {
overflow: hidden;
width: 825px;
margin-top: 50px;
margin-right: auto;
margin-left: auto;
}
body {
height: 2000px;
}
.f-box {
width: 70px;
height: 80px;
background: skyblue;
position: fixed;
left: 50%; /* 内容以浏览器中心为参照物*/
margin-left: 432px; /*内容的左外边距*/
bottom: 200px; /*内容距参照物底部距离 */
font-size: 42px; /* 文字大小*/
color: white; /*文字颜色*/
cursor: pointer; /* 鼠标小手指 */
text-align: center; /* 文字对齐方式实现文字上下居中 */
line-height: 80px; /* 行间距实现文字水平居中 */
}
</style>
</head>
<body>
<div clas