如何使中心
我想以“信息”为中心。尝试了align=的“中心”,但没有起作用
我的代码正确吗?
<table border="1" width="100%" cellspacing="10">
<tr>
<th>column1</th>
<th>column2</th>
<th bgcolor="#4F81BD"><strong><font size="5" color="white" face="calibri" align="center">Information</font><strong></th>
</tr>
</table>
编辑这里是代码,我已经建立了感谢您的答案。
<!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>
<title>Title</title>
<style type="text/css">
.centerText{
text-align: center;}
</style>
</head>
<table border="0" width="100%" cellspacing="10">
<tr>
<th></th>
<th></th>
<th class="centerText" bgcolor="#4F81BD"><strong><font size="5" color="white" face="calibri" >Information</font><strong></th>
</tr>
</table>
</body>
</html>
这是处理这个问题的正确方法吗?
发布于 2012-01-09 06:22:22
在您的代码中,您将align="center"
放到strong
中的font
标记中。所有这些元素都是内联的,并不适合所有的单元格宽度。要使其对齐,您需要将该属性放置到th
标记中,或者将string
和font
标记的显示更改为display:block
,以适应所有宽度。
最简单的方法是在CSS中:
table tr th { text-align:center; }
更好的方法是将所有内联样式移动到CSS文件中。
发布于 2012-01-09 06:21:24
尝试使用CSS。
table th {text-align:center;}
发布于 2012-01-09 06:22:18
https://stackoverflow.com/questions/8789814
复制相似问题