CSS nowrap for other than text elements?

cur4so picture cur4so · Apr 7, 2013 · Viewed 50k times · Source

Is there a way to avoid wrapping of a div's content when the content is not just text e.g. several buttons?

Answer

sachleen picture sachleen · Apr 7, 2013

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