h1标签无法居中显示

继欢是黑蛋舅舅 2011-07-29 11:12:05
代码如下,该页面想让h1标签的内容居中显示,不过在ie8,谷歌,ie6,opera浏览器都是偏左显示,没有居中,检查了好一会也没有检查出来,希望朋友能帮忙看一下源码,谢谢了!


<!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=gb2312" />
<title>无标题文档</title>
<link rel="stylesheet" type="text/css" href="css.css" />
</head>

<body>
<div id="wrapper">
<h1>表格标题栏</h1>
<div class="content">
</div>
</div>
</body>
</html>


* { margin:0px; padding:0px;}
.clearit { clear:both;}
li { list-style:none;}

body{
width:989px;
height:748px;
padding:20px 10px 0px 15px;
text-align:center;
background:#fff url(images/mainbg.gif) no-repeat bottom;
font:"宋体",Verdana, Arial, Helvetica, sans-serif;

}
#wrapper{
width:989px;
height:748px;
margin:0 auto;
text-align:center;
}
#wrapper h1 {
width:330px;
height:57px;
text-align:center;
margin:0 auto;
line-height:50px;
background:url(images/titlebg.gif) no-repeat;
font-size:20px;
color:#fff;
}

...全文
617 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ZYLBLCU 2011-07-29
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 nanshuiwuyu 的回复:]
引用 1 楼 mubeibei 的回复:


我的代码是没有问题的。因为我的屏幕分辨率是1366×768,所以造成了不居中的错觉。我将屏幕的分辨率换成1024×768,就居中了。
[/Quote]

对的~~~
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 mubeibei 的回复:]
[/Quote]

我的代码是没有问题的。因为我的屏幕分辨率是1366×768,所以造成了不居中的错觉。我将屏幕的分辨率换成1024×768,就居中了。
ZYLBLCU 2011-07-29
  • 打赏
  • 举报
回复
不知道,但是我运行是居中的
MuBeiBei 2011-07-29
  • 打赏
  • 举报
回复
<!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" />
<title>无标题文档</title>
<style>
* { margin:0px; padding:0px;}
.clearit { clear:both;}
li { list-style:none;}

body{
height:748px;
text-align:center;
background:#fff url(images/mainbg.gif) no-repeat bottom;
font:"宋体",Verdana, Arial, Helvetica, sans-serif;

}
#wrapper{
width:100%;
min-width:1002px;
height:748px;
}
#wrapper h1 {
width:330px;
height:57px;
text-align:center;
margin:0 auto;
line-height:50px;
background:url(images/titlebg.gif) no-repeat;
font-size:20px;
color:#000;
}

</style>
</head>

<body>
<div id="wrapper">
<div style="width:1002px; margin:0 auto;">
<h1>表格标题栏</h1>
<div class="content">
</div>
</div>
</div>
</body>
</html>

61,115

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧