简体   繁体   中英

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. It works on other browsers better than 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

District of
Columbia

Which is what it should be, so IE7 isn't correct with one line like District of Columbia. If I add overflow:hidden it gets cut off.

Anything about this that explains why the text will not wrap to two lines in 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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