twitter-bootstrap Bootstrap CSS - 长文本会在面板外流血
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27680765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap CSS - Long text will bleed outside of a panel
提问by user985723
I have a very long string that I'd like to put into a panel using the Bootstrap CSS library. My HTML looks something like this:
我有一个很长的字符串,我想使用 Bootstrap CSS 库将其放入面板中。我的 HTML 看起来像这样:
<div class="panel panel-primary">
<div class="panel-heading">Panel</div>
<div class="panel-body">
rPjW^j)hkP9WHwkyP_LjjzX.f9F5CsX2S9aKu4nFgJKW3Czv^bLUjbdy,rPjW^j)hkP9WHwkyP_LjjzX.f9F5CsX2S9aKu4nFgJKW3Czv^bLUjbdy,rPjW^j)hkP9WHwkyP_LjjzX.f9F5CsX2S9aKu4nFgJKW3Czv^bLUjbdy,rPjW^j)hkP9WHwkyP_L
</div>
</div>
The result is that the text bleeds outside of the panel and I'd rather it word wrap inside the panel. The problem is that the text has no spaces so natural word wrap doesn't work here. How can I force it to word wrap anyways?
结果是文本在面板外流血,我宁愿它在面板内自动换行。问题是文本没有空格,所以自然自动换行在这里不起作用。无论如何,我怎样才能强制它自动换行?
回答by maioman
you're missing this
你错过了这个
.panel-body {
word-break:break-all
}
回答by AVAVT
I think word-wrap: break-word;for .panel-body is what you need.
我认为word-wrap: break-word;.panel-body 是你所需要的。

