我们可以通过为表格添加white-space:nowrap样式设置表格内容不换行。
示例:
<style type="text/css"> .dt {table-layout:fixed; width:100px;} .dt td, .dt th{white-space:nowrap;overflow:hidden;} </style> <table class="dt"> <tr> <td>文字1文字2文字3文字4文字5文字6文字7文字文字文字文字文字文字 文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字</td> </tr> </table>
效果如下:
文字1文字2文字3文字4文字5文字6文字7文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字 |
white-space 属性设置如何处理元素内的空白。
可能的值:
更多相关知识请关注前端学习网站