☆提出问题:<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> </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> [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18