圣杯布局

flex应用之一

如果是小屏幕,躯干的三栏自动变为垂直叠加。隐藏aside

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>layout</title>
</head>
<style type="text/css">
.header {
height: 120px;
background: aliceblue;
}
.footer{
height: 120px;
background:aqua ;

}

.HolyGrail-body{
min-height: 400px;
display: flex;
flex: 1;
}
.HolyGrail-content{
flex: 1;
background: blueviolet;
}
.HolyGrail-nav, .HolyGrail-ads{
flex: 0 0 200px;
background: yellow;
}
.HolyGrail-ads{
background: chartreuse;
}
.HolyGrail-nav{
order:-1
}
@media(max-width: 768px){
.HolyGrail-body{
flex-direction: column;
flex: 1;
}
.HolyGrail-nav,.HolyGrail-content{
flex: auto;
}
.HolyGrail-ads{
display: none;
}
}
</style>
<body>
<header class="header">header</header>
<div class="HolyGrail-body">
<main class="HolyGrail-content">main</main>
<nav class="HolyGrail-nav">nav</nav>
<aside class="HolyGrail-ads">aside</aside>
</div>
<footer class="footer">footer</footer>
</body>
</html>
感谢你的打赏哦!