HTML和CSS智能自动换行?
我正在努力使我的网站在桌面和移动设备上都能正确显示。 我现在面临的问题是文本从容器中流出(并且超出了移动浏览器的边界)。正文由一些网址组成 我知道单词break:break all CSS属性,但在更改其值之前,我注意到我的默认浏览器Dolphin browser(Android设备) 我知道这种行为可能与浏览器本身有关。我想知道是否有一种方法可以在所有浏览器上实现相同的结果,而不是使用CSS分词属性,这将导致 编辑: 一个框的HTML代码为:HTML和CSS智能自动换行?,html,css,line-breaks,Html,Css,Line Breaks,我正在努力使我的网站在桌面和移动设备上都能正确显示。 我现在面临的问题是文本从容器中流出(并且超出了移动浏览器的边界)。正文由一些网址组成 我知道单词break:break all CSS属性,但在更改其值之前,我注意到我的默认浏览器Dolphin browser(Android设备) 我知道这种行为可能与浏览器本身有关。我想知道是否有一种方法可以在所有浏览器上实现相同的结果,而不是使用CSS分词属性,这将导致 编辑: 一个框的HTML代码为: <div class
<div class="col-30 col-m-30">
<div class="shadow-box wow fadeInRight">
<p><img src="/_common/_images/_soundcloudicon/dark_128.png"/></p>
<h3>SoundCloud</h3>
<div style="height: 4px; width: 128px; background-color: rgb(15, 15, 30); margin: 4px auto;"></div>
<a href="https://www.soundcloud.com/thelastminutemusic"><p>www.soundcloud.com/thelastminutemusic</p></a>
</div>
</div>
可以使用标记在特定位置断开链接
当一个单词太长,或者您担心浏览器会崩溃时
如果您的行位于错误的位置,则可以使用元素添加
断字机会
您应该将其添加到您希望文本中断的位置:
<a href="https://www.soundcloud.com/thelastminutemusic"><p>www.soundcloud.com/<wbr>thelastminutemusic</p></a>
您想要的是这段css:
.dont-break-out {
/* These are technically the same, but use both */
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
word-break: break-word;
/* Adds a hyphen where the word breaks, if supported (No Blink) */
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}
无耻地抄袭CSS技巧:请在这里输入一些代码@jiff更新了帖子。如果我正确理解了您的问题,您是否正在尝试为所有URL实现以下格式:www.domain.com/(linebreakhere)restofurl/?谢谢,它非常有效!我认为这是这种情况下最好的解决办法
.dont-break-out {
/* These are technically the same, but use both */
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
word-break: break-word;
/* Adds a hyphen where the word breaks, if supported (No Blink) */
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}