浮动之-----浮(注意看代码以及效果区别)
<style>
/* 第一个盒子浮上来,第二个盒子顶在第一个盒子原来得位置 */
.nav {
float: left;
width: 400px;
height: 400px;
background-color: blue;
}
.nb {
/* float: left; */
width: 800px;
height: 800px;
background-color: pink;
}
</style>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.nav {
width: 400px;
height: 400px;
background-color: blue;
}
.nb {
float: left;
width: 800px;
height: 800px;
background-color: pink;
}
</style>
</head>
<body>
<div class="nav"></div>
<div class="nb"></div>
</body>
</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>
<style>
/* 特:加了float后变成行内块元素,所以是并排排列,且没缝隙,特性改变 */
.nav {
float: left;
width: 400px;
height: 400px;
background-color: blue;
}
.nb {
float: left;
width: 400px;
height: 400px;
background-color: pink;
}
</style>
</head>
<body>
<div class="nav"></div>
<div class="nb"></div>
</body>
</html>