简体   繁体   中英

Word-wrap: break-word does not work with a very long word combined with width: 100%

Why is it in this fiddle https://jsfiddle.net/0h1wbju0/ my word-wrap: break word and width: 100% aren't being respected and the long word is not being broken up into multiple lines to fit inside it's parent div? Thanks!.

HTML:

    <div class="first_div">
        <fieldset class="fieldset_description"><label>Description</label>
            <div data-id="description"> fdsjalllffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff</div>
        </fieldset>
    </div>

CSS:

.first_div {
  width: 200px;
}

.fieldset_description {
  max-width: 100%;
  word-wrap: break-word;
}

.description {
  max-width: 100%;
  word-wrap: break-word;
}

you should use =>

`word-break: break-all;`

Working code jsfiddle

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