废话不多说直接上代码
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>css真正的精髓</title>
<style>
*{
margin: 0;
padding: 0;
color:#fff;
}
#container {
min-width: 1260px;
width:1260px;
height:100vh;
margin: 0 auto;
}
#header {
background: rgb(128, 226, 149);
height:70px;
}
#content {
/* 内容区 利用calc计算属性*/
min-height: calc(100vh - 70px - 100px);
/* min-height: 1000px; */
background: rgb(209, 149, 149);
}
#footer {
height: 100px;
background: #333;
}
.white{
color: #fff;
}
</style>
</head>
<body>
<div id="container">
<!-- <div id="header">网页头部</div>
<div id="content" class="white">网页内容</div>
<div id="footer" class="white">网页底部</div> -->
<!-- h5 语义化 -->
<header id="header">网页头部</header>
<main id="content">网页内容</main>
<footer id="footer">网页底部</footer>
</div>
</body>
</html>
效果
一个最小宽度 配合居中显示的这么一个布局方式
然后可以弃用浏览器的滚动条 给网页主题内容 content 加个滚动条就可以了 这种布局方式几乎适配主流显示器
用到了计算属性 calc()