# 圣杯布局
# 圣杯布局代码
<!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>
* {
padding: 0;
margin: 0;
}
body {
text-align: center;
position: relative;
min-width: 800px;
--aside-width: 200px;
--main-width: 500px;
--offset-width: -200px;
}
header, footer {
height: 40px;
}
main, .wrapper aside {
height: var(--main-width);
width: var(--aside-width);
position: relative;
}
header {
background-color: aqua;
}
main {
background-color: antiquewhite;
width: 100%;
}
body aside:nth-of-type(1) {
background-color: red;
margin-left: -100%;
left: var(--offset-width);
}
body aside:nth-of-type(2) {
background-color: gold;
margin-left: var(--offset-width);
right: var(--offset-width);
}
footer {
background-color: skyblue;
}
main, aside {
float: left;
}
.clearfix::after {
content: "";
display: block;
clear: both;
}
.wrapper {
padding: 0 var(--aside-width);
}
</style>
</head>
<body>
<header>头部区域</header>
<div class="clearfix wrapper">
<main>主区域</main>
<aside>侧边栏</aside>
<aside>侧边栏</aside>
</div>
<footer>底部区域</footer>
</body>
</html>
← 前端笔记