Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS nowrap for other than text elements?

Tags:

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

like image 676
cur4so Avatar asked Apr 06 '13 23:04

cur4so


People also ask

How do I stop text wrapping in CSS?

If you want to prevent the text from wrapping, you can apply white-space: nowrap; Notice in HTML code example at the top of this article, there are actually two line breaks, one before the line of text and one after, which allow the text to be on its own line (in the code).

Can I use overflow-wrap anywhere?

The overflowing word that is otherwise unbreakable is broken into chunks of text using overflow-wrap: anywhere so that it fits in its container. It's important to note that anywhere is not yet supported by some browsers. The image below shows the browser support according to caniuse.com.

What does Nowrap mean in CSS?

nowrap : Multiple whitespaces are collapsed into one, but the text doesn't wrap to the next line.

How do I create a white-space in CSS?

Spaces in HTML With CSS In CSS, you can use either the margin or padding properties to add space around elements. Additionally, the text-indent property adds space to the front of the text, such as for indenting paragraphs.


1 Answers

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

like image 99
sachleen Avatar answered Oct 28 '22 23:10

sachleen