所以我有这个文本如果太长需要中断:如果单词中有连字符或空格,它应该中断。有没有一种css风格可以做到这一点?
我得到的最接近的是使用 word-wrap:break-word,它适用于 Chrome,但不适用于 Firefox。这是它在 FF 中的样子:
这是我尝试过的其他事情:
Max-Width - 这在过去对我有用,但它没有影响。
这是它的外观,就像我在 fiddle或 Chrome 上的代码一样,它在连字符处中断:
这是小提琴中的代码:
<style>
.landing-sem-left, .landing-seo-left, .specials-top-left {
max-width: 460px;
padding-right: 30px;
}
.landing-sem-left, .landing-sem-middle, .landing-seo-left, .landing-seo-middle, .specials-top-left, .specials-top-middle {
padding-bottom: 23px;
}
.landing-sem-left, .landing-sem-right, .landing-sem-middle, .landing-seo-left, .landing-seo-right, .landing-seo-middle, .specials-top-left, .specials-top-right, .specials-top-middle {
border: 0 none;
float: left;
margin: 0;
overflow: hidden;
padding: 0;
}
#view-specials .heading-holder, #view-browse .heading-holder {
margin-bottom: 18px;
padding-right: 0 !important;
}
.block, .heading-holder {
display: block;
max-width: 461px;
overflow: hidden;
padding: 0 30px 0 0;
}
#view-specials .heading-holder, #view-browse .heading-holder {
margin-bottom: 18px;
padding-right: 0 !important;
width: 100% !important;
word-wrap: break-word;
}
.block, .heading-holder {
clear: both;
display: block;
float: left;
max-width: 461px;
overflow: hidden;
padding: 0 30px 0 0;
}
#landing-sem-container .h1-size1, #landing-seo-container .h1-size1 {
font-size: 30px !important;
}
.heading-holder .h1-size1 {
color: #003D77;
font-size: 30px;
line-height: 30px;
}
.heading-holder h1 span {
border: 0 none;
display: block;
font-family: Helvetica,Arial,sans-serif;
margin: 0;
padding: 0;
text-transform: uppercase;
}
.heading-holder h1 span {
color: #008CC1;
display: block;
font-size: 36px;
line-height: 38px;
margin: 0 0 -10px;
}
#landing-sem-container .h1-size3, #landing-seo-container .h1-size3, #specials-top-container .h1-size3 {
font-size: 60px !important;
line-height: 72px !important;
max-width: 461px;
width: auto;
}
.heading-holder .h1-size3 {
color: #008CC1;
font-size: 54px;
letter-spacing: -1px;
line-height: 50px;
}
.heading-holder h1 span {
display: block;
margin: 0;
padding: 0;
text-transform: uppercase;
}
</style>
<div class="landing-seo-left">
<div class="heading-holder">
<h1>
<span class="h1-size1">PRE-OWNED</span>
<span class="h1-size3">
Mercedes-Benz
</span>
</h1>
</div>
<div class="landing-seo-content">
<p>
Auto Lenders is a no-haggle, pre-owned car dealership with <a class="blue-bold-link" href="/store-locator/">5 New Jersey locations</a>. Browse our entire used Mercedes inventory below.
</p>
</div>
<div class="landing-seo-content-smaller">
<p>
Our <a class="blue-bold-link" href="#">Mercedes inventory</a> is updated often. If you don't see what you're looking for, call <strong>888-305-5968</strong> or hit ‘Subscribe to Search’ below to be notified when new matches arrive.
</p>
</div>
</div>
我不关心IE。