通过语义化标签和 float 实现以下的布局:
HTML 部分
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="demo.css">
<title>Demo</title>
</head>
<body>
<div class="contaniner">
<header>公司 LOGO</header>
<nav>
<ul>
<li>首页</li>
<li>学习</li>
<li>视频</li>
<li>关于我</li>
</ul>
</nav>
<article class="article-main">
<article>文章内容2
<section>2-1</section>
<section>2-2</section>
</article>
<aside>侧边栏</aside>
</article>
<footer>页尾</footer>
</div>
</body>
</html>
CSS 部分
.contaniner {
max-width: 700px;
position: relative;
outline: 1px red solid;
margin: 0 auto;
}
header {
height: 30px;
background-color: azure;
}
nav {
height: 60px;
background-color: aquamarine;
}
nav ul{
margin: 0;
list-style-type: none;
padding-left: 0;
}
nav li {
display: inline-block;
}
.article-main {
float: left;
}
.article-main article{
height: 300px;
width: 500px;
float: left;
background-color: lightsalmon;
}
.article-main article section {
margin-left: 30px;
}
aside {
float: right;
width: 200px;
height: 300px;
background-color: lightpink;
}
footer {
width: 700px;
background-color: gray;
height: 60px;
clear: both;
}