简体   繁体   English

使用display:table-row在HTML表格中自动换行

[英]Word-wrap in an HTML table using display:table-row

A more complex version of: Word-wrap in an HTML table . 更复杂的版本: 在HTML表中自动换行

I'm trying to create a nice mobile version of my table. 我正在尝试为表格创建一个不错的移动版本。 I'm using bootstrap media-queries to apply two CSS rules: 我正在使用引导媒体查询来应用两个CSS规则:

  1. display:table-row; - This puts each cell on a new row. -这会将每个单元格放在新行上。
  2. word-wrap:break-word; - This makes long words go over multiple lines. -这使长单词跨越多行。

The trouble is that these two rules seem to conflict. 问题在于这两个规则似乎冲突。 When I use display:table-row; 当我使用display:table-row; , the text does not wrap. ,文字不会自动换行。 Removing display:table-row; 删除display:table-row; causes text to wrap again. 使文本再次换行。

Is there any way I can use both display:table-row; 有什么办法可以同时使用display:table-row; and word-wrap:break-word; word-wrap:break-word; ?

jsfiddle with code: http://jsfiddle.net/q46Vd/ 带有代码的jsfiddle: http//jsfiddle.net/q46Vd/

尝试word-break: break-word而不是word-wrap: break-word

Solved it. 解决了。 I replaced display:table-row with display:block . 我用display:block替换了display:table-row

http://jsfiddle.net/q46Vd/1/ http://jsfiddle.net/q46Vd/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM