
代码:
<!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">
<title>Document</title>
<style>
* {
text-align: center;
border-radius: 15px;
margin: 0 auto 15px;
color: white;
font-size: 20px;
}
header {
width: 800px;
height: 100px;
line-height: 100px;
margin-top: 20px;
background-color: salmon;
}
nav {
width: 800px;
height: 50px;
line-height: 50px;
background-color: darkcyan;
}
section {
width: 800px;
background-color: sandybrown;
}
article {
position: relative;
float: left;
width: 392.5px;
height: 200px;
background-color: skyblue;
margin-right: 15px;
}
article>section {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
width: 250px;
height: 80px;
line-height: 80px;
background-color: wheat;
}
aside {
float: left;
width: 392.5px;
height: 200px;
background-color: darkorange;
}
article>span,
aside>span {
display: inline-block;
margin-top: 20px;
}
footer {
clear: both;
width: 800px;
height: 100px;
line-height: 100px;
background-color: palegreen;
}
</style>
</head>
<body>
<header>
<span><header></span>
</header>
<nav>
<span><nav></span>
</nav>
<section>
<article>
<span><article></span>
<section>
<span><section></span>
</section>
</article>
<aside>
<span><aside></span>
</aside>
</section>
<footer>
<footer>
</footer>
</body>
</html>

本文通过实例演示了如何使用HTML和CSS实现网页的基本布局,包括header、nav、section等元素的定位与样式设置。
495

被折叠的 条评论
为什么被折叠?



