怎么让文字居中在整个网页正中间?

凉粉zzz 2011-11-09 01:57:37
做了一个网页有两种风格,黑色和白色
在进入主页的时候我想设置两个按钮,一个是黑色一个是白色
怎么让这两个按钮在网页的正中间呀。不管窗口如何变大变小。
...全文
8632 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
凉粉zzz 2011-11-09
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 sunen2011 的回复:]

HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-T……
[/Quote]
谢谢,你的也可以
凉粉zzz 2011-11-09
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 hailinger14 的回复:]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<table width="100%" height="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="middle" align="……
[/Quote]
谢谢 你的很有用
茉路 2011-11-09
  • 打赏
  • 举报
回复
用position:absolute;绝对定位
sunen 2011-11-09
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Vertical centering in valid CSS</title>
<style type="text/css">
body {padding: 0; margin: 0; font-size: 75%; line-height: 140%; font-family:Arial, Helvetica, sans-serif;}
body,html{height: 100%; }
a{color: #333;}
a:hover{color: green;}
#outer {height: 100%; overflow: hidden; position: relative;width: 100%; background:ivory; }
#outer[id] {display: table; position: static;}
#middle {position: absolute; top: 50%;text-align:center;} /* for explorer only*/
#middle[id] {display: table-cell; vertical-align: middle; position: static;}
#inner {position: relative; top: -50%;width: 600px;margin: 0 auto;text-align:left;}/*for explorer only */
div.greenBorder {border: 1px solid green; background-color: #FFF;}
p{margin: 1em;}
</style>

</head>
<body>
<div id="outer">
<div id="middle">
<div id="inner" class="greenBorder">
<table><tr><td>我就喜欢在中间</td></tr></table>
</div>
</div>
</div>
</body>
</html>
hailinger14 2011-11-09
  • 打赏
  • 举报
回复
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<table width="100%" height="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="middle" align="center">
按钮
</td>
</tr>
</table>
</body>
</html>
凉粉zzz 2011-11-09
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 javaisnotmylove 的回复:]

<font align="center"></font>
[/Quote]
这个没用。只有左右居中 不能上下居中
javaisnotmyLove 2011-11-09
  • 打赏
  • 举报
回复
<font align="center"></font>

61,127

社区成员

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

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