请教css 表格居中;谢谢!
<html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/><title>...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>表格布局08 8.12</title>
<style type="text/css">
<!--
table {
margin:0 auto;
text-align: center;
}
-->
</style>
</head>
<body>
<table width="767" height="122" border="0" cellpadding="0" cellspacing="1">
<tr>
<td width="180"><p> </p>
<p> </p></td>
<td width="584" valign="top"><table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td height="103"> </td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="767" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="765"><hr></td>
</tr>
</table>
<table width="767" height="328" border="0" cellpadding="0" cellspacing="1">
<tr>
<td width="180" valign="top"><p> </p>
</td>
<td width="584" valign="top"><p> </p></td>
</tr>
</table>
<table width="765" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="763"> </td>
</tr>
</table>
<p> </p>
</body>
</html>
我想要整个表格都居中,这份HTML代码表格水平线做测试;我不想每个表格都设置属性align 。想用css来实现;请问可以做到吗 ? 谢谢!!!
我找到答案了;谢谢! body{font-size:12px;text-align:center;margin:0px auto;} 展开
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>表格布局08 8.12</title>
<style type="text/css">
<!--
table {
margin:0 auto;
text-align: center;
}
-->
</style>
</head>
<body>
<table width="767" height="122" border="0" cellpadding="0" cellspacing="1">
<tr>
<td width="180"><p> </p>
<p> </p></td>
<td width="584" valign="top"><table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td height="103"> </td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="767" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="765"><hr></td>
</tr>
</table>
<table width="767" height="328" border="0" cellpadding="0" cellspacing="1">
<tr>
<td width="180" valign="top"><p> </p>
</td>
<td width="584" valign="top"><p> </p></td>
</tr>
</table>
<table width="765" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="763"> </td>
</tr>
</table>
<p> </p>
</body>
</html>
我想要整个表格都居中,这份HTML代码表格水平线做测试;我不想每个表格都设置属性align 。想用css来实现;请问可以做到吗 ? 谢谢!!!
我找到答案了;谢谢! body{font-size:12px;text-align:center;margin:0px auto;} 展开
1个回答
展开全部
哪里有水平线。。。。。。
-------------------------------
1.在你的table外面加一个<div style="text-align:center"></div>
也就是在你的<body>里面加上这个东西
2.修改你的style定义.把table的text-align值改为left
<style type="text/css">
<!--
table {
margin:0 auto;
text-align: left;
}
-->
</style>
完整的代码是
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>表格布局08 8.12</title>
<style type="text/css">
<!--
table {
margin:0 auto;
text-align: left;
}
-->
</style>
</head>
<body>
<div style="text-align:center "><table width="767" height="122" border="0" cellpadding="0" cellspacing="1">
<tr>
<td width="180"><p> </p>
<p> </p></td>
<td width="584" valign="top"><table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td height="103"></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="767" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="765"><hr></td>
</tr>
</table>
<table width="767" height="328" border="0" cellpadding="0" cellspacing="1">
<tr>
<td width="180" valign="top"><p> </p>
</td>
<td width="584" valign="top"><p> </p></td>
</tr>
</table>
<table width="765" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="763"> </td>
</tr>
</table></div>
<p> </p>
</body>
</html>
-------------------------------
1.在你的table外面加一个<div style="text-align:center"></div>
也就是在你的<body>里面加上这个东西
2.修改你的style定义.把table的text-align值改为left
<style type="text/css">
<!--
table {
margin:0 auto;
text-align: left;
}
-->
</style>
完整的代码是
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>表格布局08 8.12</title>
<style type="text/css">
<!--
table {
margin:0 auto;
text-align: left;
}
-->
</style>
</head>
<body>
<div style="text-align:center "><table width="767" height="122" border="0" cellpadding="0" cellspacing="1">
<tr>
<td width="180"><p> </p>
<p> </p></td>
<td width="584" valign="top"><table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td height="103"></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="767" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="765"><hr></td>
</tr>
</table>
<table width="767" height="328" border="0" cellpadding="0" cellspacing="1">
<tr>
<td width="180" valign="top"><p> </p>
</td>
<td width="584" valign="top"><p> </p></td>
</tr>
</table>
<table width="765" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="763"> </td>
</tr>
</table></div>
<p> </p>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询