Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:不管多复杂的页面, 只要是由矩形块组成, 就可以用grid搞定它
.col-12 {
grid-column: span 12;
}
.col-11 {
grid-column: span 11;
}
.col-10 {
grid-column: span 10;
}
.col-9 {
grid-column: span 9;
}
.col-8 {
grid-column: span 8;
}
.col-7 {
grid-column: span 7;
}
.col-6 {
grid-column: span 6;
}
.col-5 {
grid-column: span 5;
}
.col-4 {
grid-column: span 4;
}
.col-3 {
grid-column: span 3;
}
.col-2 {
grid-column: span 2;
}
.col-1 {
grid-column: span 1;
}
css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
min-width: 98vw;
min-height: 100vh;
display: grid;
place-content: center;
}
a{text-decoration: none;
color: #333;}
.container {
display: grid;
min-width: 98vw;
gap: 1em;
}
.item{
background-color: aquamarine;
width: 100%;
height: 100%;
}
.container > .top,header,.banner,main,footer {
display: grid;
grid-template-columns: repeat(12, 1fr);
gap: 0.5em;
}
header,.banner,main{
width: 80vw;
margin: auto;
}
.container > .top {
font-size: 0.75em;
min-height: 3vh;
line-height: 3vh;
background-color: #ccc;
}
.container > .top >.item {
background-color: #ccc;
}
.container > .top >.item > .top_left {
text-align: left;
margin-left: 10em;
}
.container > .top >.item > .top_right {
text-align: right;
margin-right: 10em;
}
.container > header {
min-height: 15vh;
}
.container > .banner {
min-height: 50vh;
}
.container > main {
min-height: 30vh;
}
.container > footer {
min-height: 30vh;
}
.item {
text-align: center;
}
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>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="top">
<span class="item col-6">
<div class="top_left">
<a href="">欢迎来到xxx </a>
<a href="">| 商务中心 </a>
<a href="">| 站内信(0) </a>
<a href="">| 新交谈(0) </a>
<a href="">| 退出登录 </a>
</div>
</span>
<span class="item col-6">
<div class="top_right">
<a href="">买家中心 </a>
<a href="">| 卖家中心 </a>
<a href="">| 客户服务 </a>
<a href="">| 我的采购(2) </a>
</div>
</span>
</div>
<header>
<span class="item col-3">
<div class="logo">logo</div>
</span>
<span class="item col-7">
<div class="search">search</div>
</span>
<span class="item col-2">
<div class="vx">vx</div>
</span>
</header>
<div class="banner">
<span class="item col-2">side</span>
<span class="item col-6">banner</span>
<span class="item col-2">assbanner</span>
<span class="item col-2">side</span>
</div>
<main>
<span class="item col-3">main</span>
<span class="item col-3">main</span>
<span class="item col-3">main</span>
<span class="item col-3">main</span>
</main>
<footer>
<span class="item col-12">banner</span>
</footer>
</div>
</body>
</html>
案例图片