例如,on this site中心有主要内容,最右边和左边有纯白色背景。这个设计风格叫什么?我怎么能用CSS做到这一点?
答案 0 :(得分:1)
我认为它没有名字。它是一个中心定义宽度的容器。
试试这个:
HTML:
<div class="container">
//Content here
</div>
CSS:
body{
background-color:#eee;
}
.container{
width:960px;
margin:auto;
background-color:#fff;
border:1px solid #ccc;
}
答案 1 :(得分:1)
我不知道它是如何调用的,或者它是否有一个名称(我只称它为固定宽度,居中的内容),但它是这样实现的:
<!DOCTYPE html>
<meta charset="utf-8">
<title>My Site</title>
<main>
<!-- Your main content goes here -->
</main>
body {
/* The color of the stripes left and right */
background-color: white;
}
main {
/* Define the width here */
max-width: 960px;
/* Center it */
margin: 0 auto;
/* Your content background */
background-color: #f0f0f0;
/* Optionally add separating lines and shadow: */
border: 1px solid #eee;
border-top: none;
box-shadow: 0 0 5px #aaa;
}