[英]CSS word-wrap: break-word not wrapping a tag unless you wrap it in div and add rule there
why does CSS rule CSS为什么统治
a {
word-wrap: break-word;
}
with 同
<div>
<a href="...">verylongurlherewithnospaces</a>
</div>
not wrapping and causing window to show scrollbar, whereas 没有包装并导致窗口显示滚动条,而
div {
word-wrap: break-word;
}
will do the wrapping at its anchor child's text fine? 将其主子文本的换行效果好吗?
UPDATE: just noticed (see L3ST-instance URL field at this form when you resize the window) that I needed word-break:break-all instead of word-wrap:break-word, apart from the suggested display:inline-block, so now using: 更新:刚才注意到(见L3ST实例URL字段在这个形式 ,当你调整窗口的大小),我需要的字符:盈亏所有,而不是自动换行:打破字,除了建议显示:inline-block的,所以现在使用:
a
{
word-break: break-all !important; /* make sure containers don't override */
display: inline-block !important;
}
which works fine 哪个很好
The CSS word-wrap: break-word;
CSS
word-wrap: break-word;
works only in display:block;
仅适用于
display:block;
or display:inline-block;
或
display:inline-block;
elements so you can just use: 元素,因此您可以使用:
a {
display:inline-block;
word-wrap: break-word;
}
a { width:100px; word-wrap: break-word; display:inline-block; }
<div> <a href="...">verylongurlherewithnospaces</a> </div>
PS div
are display:block;
PS
div
是display:block;
as default by user-agent. 默认为用户代理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.