我想创建一个网站,背景是一种颜色,中心内容部分是另一种颜色。我有麻烦设置自定义标签来实现这一点。我有:
自定义正文标签-
<body style="background-color: #000000" >
<div style="text-align:right; padding: 10px; background-color:white; width:800px">
<jsp:doBody />
</div>
<n:footer></n:footer>
</body>
在我看来,我在jsp上的自定义正文标记之间包含的任何内容都应该具有background-color = white,并且周围的所有内容都应该是color = #000000。事实并非如此。相反,我在页面上只有一个10px高的带。我做错了什么?
如果没有内容,<div>
会崩溃。给它一些文字
通常我只是这样做:
<body style="padding:0;margin:0;background-color:#000;">
<div style="margin:0 auto;width:800px;background-color:#fff;">This is the content</div>
</body>
因为div的左右距都是margin:auto,它会自动居中。只是要确保添加了一个width属性,否则它将无法工作。