让内容块在网页中居中显示

来源:百度知道 编辑:UC知道 时间:2024/09/28 08:29:57
有如下网页,想让红色块在网页中居中显示,也就是说,在红色块两边应该留有等宽的绿色背景
谢谢~~

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body *{
margin:0px;
padding:0px;
border:0px;
}
#wrapper{
width:900px;
height:300px;
margin:0px, auto;
background:red;
}
#ad{
width:324px;}
</style>
<title>无标题文档</title>
</head>

<body>
<div id="wrapper">
<div

你把样式这样写下!
body{background:green;}
*{margin:0 auto;padding:0px;}
#wrapper{width:900px;height:300px;margin:0px auto;background:red;}
这样应该不会有问题的!有问题再M我!

下边这里

<body>
<div id="wrapper">
<div id="ad">
<!-- </h1><<img src="pic/ad.jpg" /> -->
fffffff
</div>
</div>
</body>

改成

<center><body >
<div id="wrapper">
<div id="ad">
<!-- </h1><<img src="pic/ad.jpg" /> -->
fffffff
</div>
</div>
</body>
</center>

就可以了 也就是整体前后分别加个 </center>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "如何让DIV层在网页中居中显示 我用fireworks做的内容,如何让他在网页中居中? 如何在VB中对窗体内容居中显示 在网页中嵌入透明的flash,怎样才能居中显示? 如何在Dreamweaver中让网页整体居中? 在JTextField中如何设置让文字居中显示? 如何让网页居中显示?急~~谢谢~~ 网页显示不居中 如何让网页居中? 怎么用HTML编写使播放器在网页中居中显示