[英]HTML td will not break to new line with <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
我遇到了讓表格單元格按預期響應樣式的問題。 請不要建議使用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 & 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 & Conditions</a>
</td>
</tr>
</tbody>
</table>
</body>
</html>
這是我期望看到的:
這就是我所看到的:
任何人都有任何見解為什么doctype沒有在自己的行上設置td? 我正在使用Chrome。 我檢查了Firefox,它按預期工作。
如上所述:
我確實找到了啟用松散定義“w3.org/TR/html4/loose.dtd”的能力; 這解決了這個問題。
參考
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.