如何使用 Twitter Bootstrap 3 将长单词包装在容器内?
How to wrap long word inside container using Twitter Bootstrap 3?
这是我的 html:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container-fluid">
<div class="row post img-rounded">
<span>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span>
</div>
</div>
问题是,最终用户选择了范围内的内容。如果 span 内的内容是一个很长的单词,则会出现水平滚动条,并且该单词会延伸到 div 之外。是否有一种非 hacky(可能是 Twitter Bootstrap 3)的方式来基本上包装单词,使其不会延伸到 div 之外,从而导致水平滚动条?
如果不是,解决问题的最佳方法是什么?
要中断,请使用 word-wrap: break-word
,但您缺少 bootstrap col-*-*
包装 span
.row div {
background: red
}
.row:first-of-type span {
word-wrap: break-word
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<div class="row post img-rounded">
<div class="col-xs-2">
<span>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span>
</div>
</div>
<hr />
<div class="row post img-rounded">
<div class="col-xs-2">
<span>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span>
</div>
</div>
</div>
这是我的 html:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container-fluid">
<div class="row post img-rounded">
<span>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span>
</div>
</div>
问题是,最终用户选择了范围内的内容。如果 span 内的内容是一个很长的单词,则会出现水平滚动条,并且该单词会延伸到 div 之外。是否有一种非 hacky(可能是 Twitter Bootstrap 3)的方式来基本上包装单词,使其不会延伸到 div 之外,从而导致水平滚动条?
如果不是,解决问题的最佳方法是什么?
要中断,请使用 word-wrap: break-word
,但您缺少 bootstrap col-*-*
包装 span
.row div {
background: red
}
.row:first-of-type span {
word-wrap: break-word
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<div class="row post img-rounded">
<div class="col-xs-2">
<span>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span>
</div>
</div>
<hr />
<div class="row post img-rounded">
<div class="col-xs-2">
<span>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span>
</div>
</div>
</div>