跨越分裂,如何避免?

时间:2011-07-16 21:27:26

标签: css html wrapping

问题在于:http://jsfiddle.net/STG22/3/

我希望跨度不会分成两个不同的行(如上例中的第三行)。我该怎么办?


CSS:

span
{
    background: red;
    border-radius: 5px;
    width: 60px;
}

HTML:

<div style="width: 250px">
    <span>omg omg omg</span>
    <span>omg omg omg</span>
    <span>omg omg omg</span>
    <span>omg omg omg</span>
</div>

3 个答案:

答案 0 :(得分:6)

答案 1 :(得分:0)

您可以将css属性white-space设置为nowrap,这会因空间限制而停止换行

答案 2 :(得分:0)

使用white-space:nowrapdisplay:inline-block(未设置width)。

如果您不知道:width不会影响<span>等内联元素。

相关问题