html表想要了解更好的方法

时间:2013-02-01 14:36:48

标签: html css html5 css3

我有这个旧代码:

<html>
<head>
<body style="text-align:center;">
<style>
#wrapper{margin:0 auto; max-width:992px;}
</style>
<div id="wrapper">
<table border="1" width="100%" height="40px">
<tr>
<td>header</td>
</tr>
</table>
<table border="1" width="100%" height="50%">
<tr>
<td width="60%">Main Data Window</td>
<td width="40%">Right Side Buttons</td>
</tr>
</table>
<table border="1" width="100%" height="43%">
<tr>
<td>Bottom Buttons</td>
</tr>
</table>
</div>
</body>
</html>

现在因为不推荐使用表高度(所以如果我把DOCTYPE html放在文件中就会破坏它),这将是一种获得相同结果的现代方法。

基本上我想要它一样,所以在所有显示器和设备方向上,它的大小相同。

非常感谢。

1 个答案:

答案 0 :(得分:-1)

最好的办法是立即使用CSS。你可以不用它来内联:

<table border="1" style="width:100%; height:40px; border:1px solid black;">

或者创建一个类并将其应用到表中。

.tbl1{
width:100%; 
height:40px; 
border:1px solid black;
}

<table class="tbl1">

注意:使用表格进行布局也是一种不赞成使用的方式。除非您显示实际的表格数据,否则我建议您使用div,span等。