CSS:如何阻止文本占用超过1行? [英] CSS: how to stop text from taking up more than 1 line?
本文介绍了CSS:如何阻止文本占用超过1行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有单词包装或任何其他属性,阻止文本包装?我有一个高度, overflow:hidden
,文本仍然中断。
需要在所有浏览器,
$ c $ p>< div>测试不包裹< / div>
< style type =text / css>
div {
white-space:nowrap;
overflow:hidden;
}
< / style>
注意:这只适用于块元素。如果你需要这样做表格单元格(例如),你需要把一个div在表格单元格内,因为表格单元格显示表格单元格没有阻止。
从CSS3开始,表单元格也支持。
Is there a word-wrap or any other attribute that stops text from wrapping? I have a height, and overflow:hidden
, and the text still breaks.
Needs to work in all browsers, before CSS3.
解决方案
<div>test that doesn't wrap</div>
<style type="text/css">
div {
white-space: nowrap;
overflow: hidden;
}
</style>
Note: this only works on block elements. If you need to do this to table cells (for example) you need to put a div inside the table cell as table cells have display table-cell not block.
As of CSS3, this is supported for table cells as well.
这篇关于CSS:如何阻止文本占用超过1行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文