简体   繁体   English

文本不以IE7内的宽度在div中换行

[英]Text not wrapping in div with a width within IE7

In IE7 the text in a div with a width that is narrower than the text will not wrap to two lines. 在IE7中,宽度小于文本宽度的div中的文本不会换成两行。 It works on other browsers better than IE7. 它比IE7更好地在其他浏览器上运行。

<div class="office-header-info">
<div class="local-office">District of Columbia</div>
</div>
.office-header-info {
  float: left;
}

.local-office {
  color: #893f22;
  width: 165px;
  text-align: center;
  font-size: 22px;
  font-weight: bold;
  margin-top: 17px;
  white-space: normal;
  line-height: 1.1;
}

In IE7 District of Columbia stays on one line when in other browsers it is 在IE7中,哥伦比亚特区停留在一条线上,而在其他浏览器中则处于

District of 的地区
Columbia 哥伦比亚

Which is what it should be, so IE7 isn't correct with one line like District of Columbia. 这应该是正确的,因此IE7对于像哥伦比亚特区这样的一行是不正确的。 If I add overflow:hidden it gets cut off. 如果我添加了overflow:hidden,它将被切断。

Anything about this that explains why the text will not wrap to two lines in IE7? 关于此的任何解释都解释了为什么文本不会在IE7中换行为两行?

white-space: pre; /* CSS 2.0 */
white-space: pre-wrap; /* CSS 2.1 */
white-space: pre-line; /* CSS 3.0 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: -moz-pre-wrap; /* Mozilla */
white-space: -hp-pre-wrap; /* HP Printers */
word-wrap: break-word; /* IE 5+ */

Give that a go. 放手

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

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