HTML td不会破坏到新行

时间:2015-03-07 02:39:46

标签: html xhtml html-table doctype

我遇到了让表格单元格按预期响应样式的问题。请不要建议使用div和CSS。我知道它更好,但不适合这个特殊问题。我也无法更改doctype,因为它是带有封闭源的CMS。这与XHTML doctype

一样正常
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<style>
.foottable{
    width:100%;
    table-layout:fixed;
}
.foottable td{
    display: block;
    width: 100%;
}
</style>
</head>
<body>                  
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="foottable">
    <tbody>
        <tr valign="top">
            <td>
                <b>About</b>
                <a href="info.html">About</a>
                <a href="press.html">Press</a>
                <a target="_blank" href="http://blog.com/">Blog</a>
                <a href="events.html">Events</a>
                <a href="stores.html">Store Locations</a>
                <a href="ind.html">Site Map</a>
            </td>
            <td>
                <b>Customer Service</b>
                <a href="shipping.html">Shipping</a>
                <a href="returnpolicy.html">Returns</a>
                <a href="giftcert.html">Gift Certificates</a>
                <a href="privacypolicy.html">Privacy Policy</a>
                <a href="terms.html">Terms &amp; Conditions</a>
            </td>
        </tr>
    </tbody>
</table>
</body>
</html>

只要doctype是HTML 4.01,它就无法按预期工作

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style>
.foottable{
    width:100%;
    table-layout:fixed;
}
.foottable td{
    display: block;
    width: 100%;
}
</style>
</head>
<body>                  
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="foottable">
    <tbody>
        <tr valign="top">
            <td>
                <b>About</b>
                <a href="info.html">About</a>
                <a href="press.html">Press</a>
                <a target="_blank" href="http://blog.com/">Blog</a>
                <a href="events.html">Events</a>
                <a href="stores.html">Store Locations</a>
                <a href="ind.html">Site Map</a>
            </td>
            <td>
                <b>Customer Service</b>
                <a href="shipping.html">Shipping</a>
                <a href="returnpolicy.html">Returns</a>
                <a href="giftcert.html">Gift Certificates</a>
                <a href="privacypolicy.html">Privacy Policy</a>
                <a href="terms.html">Terms &amp; Conditions</a>
            </td>
        </tr>
    </tbody>
</table>
</body>
</html>

这是我期望看到的:enter image description here

这就是我所看到的: enter image description here

任何人都知道为什么doctype没有在自己的行上设置td?我正在使用Chrome。我检查了Firefox,它按预期工作。

1 个答案:

答案 0 :(得分:0)

如上所述:

  

我确实找到了启用松散定义的能力&#34; w3.org/TR/html4/loose.dtd" ;;这解决了这个问题。

<强>参考