简体   繁体   English

自动换行:断字; 不打破标签

[英]word-wrap: break-word; not breaking the <code></code> tag

i have an issue with the word-wrap break-word property, it is supposed to break the code tag that when it hits the border of我对 word-wrap break-word 属性有问题,它应该打破代码标签,当它碰到边界时

<div>class="link alert clearfix"</div>

but it is not breaking the word, it instead jumps down on the next line, next to the "voting" div但它并没有打破这个词,而是跳到下一行,在“投票”div旁边

Here is the issue:这是问题:

http://meetthemes.com/post/?post=Mooncraft+-+Themeforest+Premium+Theme http://meetthemes.com/post/?post=Mooncraft+-+Themeforest+Premium+Theme

Scroll down to the third download link, thats the one that jumps down向下滚动到第三个下载链接,那个是跳下来的

If you set it to display: inline-block and give it a max-width , it will break the word for you.如果你将它设置为display: inline-block并给它一个max-width ,它会为你打破这个词。 You'll also need to remove the white-space: nowrap on the code element in your CSS, or disable it for your specific code.link class, by adding white-space: normal .您还需要删除 CSS 中代码元素上的white-space: nowrap ,或者通过添加white-space: normal为您的特定code.link类禁用它。

John suggestion not work at all, in order to work you must use also the properties entitled in this post:约翰的建议根本不起作用,为了工作,您还必须使用这篇文章中标题为的属性:

So use below sample code:所以使用下面的示例代码:

<code style="display: inline-block;white-space: normal;max-width:100%; word-break:break-all; word-wrap:break-word;">anyyyyyyyylonnnnnngggggggggstringggggggggwillllbetrunnncateeeeeddddddd</code>

You can set any max-width, in integer PX, EM or by percentage nor just simply do not set a max-width, as it is not mandatory您可以设置任何最大宽度,整数 PX、EM 或百分比,也可以不设置最大宽度,因为它不是强制性的

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

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