一个长字符串溢出一个div容器

时间:2011-04-18 05:31:49

标签: css html overflow

如果“content”包含没有空格的长字符串,它将溢出div(“topic”)。 我怎么能解决这个问题?

现场演示在这里: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;
}

1 个答案:

答案 0 :(得分:7)

在你的风格中添加:
    自动换行:break-word;