问题
Is there a way to avoid wrapping of a div
's
content when the content is not just text e.g. several buttons?
回答1:
white-space:nowrap;
should do the trick.
#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>
Demo
回答2:
You can set both these properties in CSS:
white-space:nowrap;
and max-width:something;
回答3:
You can declare static positions for the other contents using
position:absolute;
来源:https://stackoverflow.com/questions/15857321/css-nowrap-for-other-than-text-elements