benck
benck

Reputation: 2052

a long string overflow a div container

If "content" contains a long string without a space, it will overflow outside div("topic"). How could I fix this?

A live demo is here: http://jsfiddle.net/w87Vz/

html:

<div class="topic">
    <div class="content">a longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong string</div>
</div>

css:

.topic{
background:#ddd;
margin: 0 auto;
position: relative;
display: block;
width: 300px;
}

Upvotes: 2

Views: 2527

Answers (1)

Alexander Taran
Alexander Taran

Reputation: 6725

in your style add:
word-wrap: break-word;

Upvotes: 9

Related Questions