☆提出问题:
<td width="28%" align="right" nowrap >
我设置nowrap和不设置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
>
</
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
>
<td width="28%" align="right" nowrap >
我设置nowrap和不设置nowrap效果都一样。就是表格随着文字自动伸展,为什么?
→回答问题:
TD元素noWrap属性的行为与TD元素的width属性有关。
◆如果未设置TD宽度,则noWrap属性是起作用的。
◆如果设置了TD宽度,则noWrap属性是不起作用的。
示例文件,点击运行按钮,查看效果:




































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