div溢出权利

时间:2012-11-20 16:38:28

标签: css html overflow

是否有更改div的默认行为,以便溢出:隐藏导致内容溢出div的右侧,而不是从div的底部溢出?

2 个答案:

答案 0 :(得分:3)

试试white-space:nowrap。这样内容就不会换行到新行。

div{
    overflow:hidden;
    white-space:nowrap;
    width:100px;
}

答案 1 :(得分:2)

是。文字没有换行:

<div style="width:100px;height:30px; overflow:hidden; white-space:nowrap;">
    Is there away to change the default behavior of a div so that
    overflow:hidden causes the content to overflow out the right side
    of a div, rather than out of the bottom of the div?
</div>