TD的noWrap屬性使用注意事項

 ☆提出問題:
<td width="28%" align="right" nowrap >
我設置nowrap和不設置nowrap效果都一樣。就是表格隨着文字自動伸展,爲什麼?

→回答問題:
TD元素noWrap屬性的行爲與TD元素的width屬性有關。

◆如果未設置TD寬度,則noWrap屬性是起作用的。
◆如果設置了TD寬度,則noWrap屬性是不起作用的。

示例文件,點擊運行按鈕,查看效果:

<html>
<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>&nbsp;</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>&nbsp;</td>
</tr>
</table>
</body>
</html>

文章來源:http://www.cnblogs.com/ufo0303/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章