CSS:table {width:100%; display:block;}无法在Firefox中运行

时间:2010-09-28 03:28:44

标签: html css

  

可能重复:
  CSS: table {width:100%; display:block;} not working in Firefox

我在特定大小的div中有一个html表。我希望表格应用保证金折叠并且100%宽。这是我的代码。它在IE8中呈现我想要的样子,在Firefox中呈现不正确。 Firefox可能正确地做了规范,但无论如何。如何修复我的CSS以在两种浏览器中工作?

<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>

<style type="text/css">
table
{
    border-collapse: collapse;
    border-spacing: 0;
}

table
{
    width: 100%;
    display: block; 
}

td, th
{
    border: 1px solid #000000;
}

</style>
</head>

<body>

<div style="width: 600px; border: 1px purple solid;">
<table>
    <tr>
        <th></th>
        <th>Header 1</th>
        <th>Header 2</th>
        <th>Header 3</th>
    </tr>
    <tr>
        <td>Label 1</td>
        <td>1.A</td>
        <td>1.B</td>
        <td>1.c</td>
    </tr>
    <tr>
        <td>Label 2</td>
        <td>2.A</td>
        <td>2.B</td>
        <td>2.c</td>
    </tr>
</table>
</div>

</body>

</html>

我需要display:block保证金折叠才能在Firefox中使用。

0 个答案:

没有答案
相关问题