Html 用于文本元素以外的 CSS nowrap?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15857321/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CSS nowrap for other than text elements?
提问by cur4so
Is there a way to avoid wrapping of a div
's
content when the content is not just text e.g. several buttons?
div
当内容不仅仅是文本(例如几个按钮)时,有没有办法避免包装 a的内容?
回答by sachleen
white-space:nowrap;
should do the trick.
white-space:nowrap;
应该做的伎俩。
#foo {
white-space:nowrap;
width: 100px;
}
<div id="foo">
<input type="button" value="hello"/>
<input type="button" value="hello"/>
<input type="button" value="hello"/>
<input type="button" value="hello"/>
<input type="button" value="hello"/>
<input type="button" value="hello"/>
<input type="button" value="hello"/>
</div>
回答by Muhammad Omar ElShourbagy
You can set both these properties in CSS:
您可以在 CSS 中设置这两个属性:
white-space:nowrap;
and max-width:something;
white-space:nowrap;
和 max-width:something;
回答by LoBS
You can declare static positions for the other contents using
您可以使用声明其他内容的静态位置
position:absolute;