DIV+CSS实现单栏式布局:两种常见布局方案详解
使用DIV+CSS实现单栏式布局:两种常见布局方案详解
本文将介绍使用DIV+CSS实现两种常见的单栏式布局方案,并提供详细的HTML结构和CSS样式代码示例。
布局1:所有模块等宽布局
HTML结构:
<div class='container'>
<div class='header'>Header</div>
<div class='content'>Content</div>
<div class='footer'>Footer</div>
</div>
CSS样式:
.container {
width: 100%;
}
.header, .content, .footer {
box-sizing: border-box;
padding: 20px;
}
.header {
background-color: #f2f2f2;
}
.content {
background-color: #fff;
}
.footer {
background-color: #f2f2f2;
}
布局2:header、footer等宽,content略窄布局
HTML结构:
<div class='container'>
<div class='header'>Header</div>
<div class='content'>Content</div>
<div class='footer'>Footer</div>
</div>
CSS样式:
.container {
width: 100%;
display: flex;
flex-direction: column;
}
.header, .content, .footer {
box-sizing: border-box;
padding: 20px;
}
.header, .footer {
background-color: #f2f2f2;
}
.content {
width: 80%;
margin: 0 auto;
background-color: #fff;
}
原文地址: https://www.cveoy.top/t/topic/l5sD 著作权归作者所有。请勿转载和采集!