<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>經(jīng)典布局</title>
<style>
html {
/*將整個頁面和盒子設(shè)置為內(nèi)減模式,原先默認的是content-box是外加模式,當(dāng)你添加margin、padding、border的時候都會將原來的父盒子撐大,對布局進行很多計算(如果粗心漏掉一個計算就會出不來效果,修修改改越來越煩),而使用內(nèi)減模式,就不需要這些復(fù)雜的計算*/
box-sizing: border-box;
}
*, *:before, *:after {
margin: 0;
padding: 0;
/*去除默認邊距的同時讓所有元素繼承html的box-sizing*/
box-sizing: inherit;
}
body{
background-color: #ccc;
margin: 0 auto;
text-align: center;
color:#fff;
}
/*使用html5里面的相關(guān)標(biāo)簽*/
header{
background-color: #333;
height: 50px;
padding-top: 10px;
}
nav{
width: 80%;
height: 30px;
line-height: 30px;
margin: 0 auto;
/*padding-top: 10px;*/
background-color: #bababa;
}
.container{
width: 80%;
margin: 0 auto;
/*由于內(nèi)部內(nèi)容的浮動,會對后期的修改造成影響,這里設(shè)置最小的高度來清除浮動的影響*/
min-height: 500px;
}
section{
background-color: #30a453;
height: 500px;
width: 70%;
float: left;
}
aside{
background-color: #4c77f2;
height: 500px;
width: 30%;
float: right;
}
footer{
background-color: #333;
height: 50px;
line-height: 50px;
}
</style>
</head>
<body>
<header>
<nav>我是nav標(biāo)簽</nav>
</header>
<div class="container">
<section>
<h4>這里是section</h4>
<p>我是內(nèi)容內(nèi)容我是內(nèi)容內(nèi)容我是內(nèi)容內(nèi)容我是內(nèi)容內(nèi)容我是內(nèi)容內(nèi)容我是內(nèi)容內(nèi)容我是內(nèi)容內(nèi)容我是內(nèi)容內(nèi)容我是內(nèi)容內(nèi)容我是內(nèi)容內(nèi)容我是內(nèi)容內(nèi)容我是內(nèi)容內(nèi)容我是內(nèi)容內(nèi)容</p>
</section>
<aside>這里是側(cè)邊欄</aside>
</div>
<footer>
<p>footer區(qū)域</p>
</footer>
</body>
</html>

image.png