<td width="28%" align="right" nowrap >
我設置nowrap和不設置nowrap效果都一樣。就是表格隨着文字自動伸展,爲什麼?
→回答問題:
TD元素noWrap屬性的行爲與TD元素的width屬性有關。
◆如果未設置TD寬度,則noWrap屬性是起作用的。
◆如果設置了TD寬度,則noWrap屬性是不起作用的。
示例文件,點擊運行按鈕,查看效果:
<head>
<title>wrap屬性研究</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>測試字符串:</p>
<p>我終於明白,我其實有一條韌性十足的命,它遠比我想象中的那條命結實得多、耐磨的多……</p>
<p>單元格未設置nowrap屬性的空表:</p>
<table width="100" border="1" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table>
<p>加入測試字符串:</p>
<table width="100" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>我終於明白,我其實有一條韌性十足的命,它遠比我想象中的那條命結實得多、耐磨的多……</td>
</tr>
</table>
<p>單元格設置了nowrap屬性,未設置width屬性:</p>
<table width="100" border="1" cellspacing="0" cellpadding="0">
<tr>
<td nowrap>我終於明白,我其實有一條韌性十足的命,它遠比我想象中的那條命結實得多、耐磨的多……</td>
</tr>
</table>
<p>單元格設置了nowrap屬性,也設置了width屬性:</p>
<table width="200" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="120" nowrap>我終於明白,我其實有一條韌性十足的命,它遠比我想象中的那條命結實得多、耐磨的多……</td>
<td> </td>
</tr>
</table>
</body>
</html>