【发布时间】:2015-05-29 16:09:11
【问题描述】:
我有一个基本块(紫色),里面有一些可变长度的文本。 div 是相对位置的,也是响应式的,因此它的宽度等以 % 为单位。
我们的一些用户在 Chrome 最新版 (v43.0.2357.65) 和 WinXP 上看到文本溢出到紫色框的边缘。这是一时兴起的,因此很难重现。我正在尝试修复 CSS,以便文本不会溢出。我在包含文本的 div 上也有一个 max-width 和 break-word 属性。
该网站是荷兰语。
<div class="mt-landing__section-notification">
<div class="mt-landing__section-notification__info-icon icon-info"></div>
<div class="mt-landing__section-notification__close-icon"></div>
<div class="mt-landing__section-notification__content">
<div class="mt-landing__section-notification__message">
This is where the text is.
</div>
</div>
</div>
这是最外层 div 上的 CSS 和包含文本的那个:
.mt-landing__section-notification {
z-index: 1;
width: 64.5%;
background-color: #411E4E;
padding: 20px;
color: #fff;
box-sizing: border-box;
position: relative;
float: left;
margin-top: 0px;
display: block;
}
.mt-landing__section-notification__message {
line-height: 24px;
margin-top: -3px;
word-wrap: break-word;
max-width: 100%;
}
.mt-landing__section-notification__content {
margin: 0px 50px;
}
.mt-landing__section-notification__info-icon {
width: 50px;
float: left;
font-size: 24px;
}
.info-icon {
font-family: mt-icons;
font-style: normal;
font-weight: 400;
font-variant: normal;
text-transform: none;
line-height: 1;
}
.info-icon::before {
content: '\e617';
}
任何想法为什么文本溢出?
【问题讨论】:
-
你能把你正在使用的整个字符串粘贴到 div 中吗?
-
这里是“Heeft u vanaf 23 mei een abonnementenwijziging doorgegeven?Door een systeemstoring kan he zijn dat deze wijziging nog niet is verwerkt. Wij hopen dit zo spoedig mogelijk te herstellen。借口。”但是我必须提到这个字符串是动态的,它是通过一种管理界面设置的,最终作为 html 模板上的服务器端变量。对于不同的文本,我也遇到过这个问题。
-
左边的图标是哪里来的?
-
您的 CSS 是正确的,正如 @BenPhilipp 所说,可能问题是由于左侧图标将所有内容“推”到右侧。
-
我的图标只是一个图标字体,我将字体系列定义为自定义字体和伪元素中的内容值。图标信息 { 字体样式:正常;字体粗细:400;字体变体:正常;文本转换:无;行高:1; } .icon-info:before { 内容:"\e617"; }
标签: html css cross-browser