如何用表格实现overflow:hidden
时间:2010-08-06 13:49:09 关键词:乐投亚洲制作 web
众所周知,DIV+CSS里如果文本过长可以用overflow:hidden来隐藏超出的部分,但在表格td里就不起作用了,下面举两个例子
第一种,用DIV
<div style="width:20px; white-space:nowrap; overflow:hidden;">,,,,,</div>
第二种,用td
<table><tr><td style="width:20px; white-space:nowrap; overflow:hidden;">>,,,,,</td></tr></table>
由此可见第一种是能正常隐藏的,而第二种则行不通,在这种情况下就要用到table-layout的fixed属性了
<style type="text/css">
table {width:20px;table-layout:fixed;}
td {white-space:nowrap;overflow:hidden;}
</style>
加上这段代码后,就可以实现td也自动隐藏超出文本了。
本文由重庆乐投亚洲建设服务商九度发布,网址:https://www.nafhat.biz/news/i92.html