1

I have got a div with some content inside it. Now I want to align the elements horizontally. I used display : inline;, but now I've got the problem that when an element reaches the width of the div, there is an internal linebreak. So actually I am looking for a css command that all elements are aligned horizontally AND that there won't be the linebreaks inside the div.

Thank you for your help.

oopbase
  • 11,157
  • 12
  • 40
  • 59
  • possible duplicate of [How to turn off word wrapping in HTML?](http://stackoverflow.com/questions/4652654/how-to-turn-off-word-wrapping-in-html) – Explosion Pills Jul 13 '12 at 15:38

2 Answers2

1

Use

white-space: nowrap;

on the enclosing <div> to prevent any line breaks. See the MDN docu here.

Sirko
  • 72,589
  • 19
  • 149
  • 183
  • This works, but how can I prevent the elements that overflow to be hidden? overflow: hidden; doesn't seem to work – oopbase Jul 13 '12 at 15:42
  • 1
    @Forlan07 `overflow: hidden` will only work, if the `
    ` is set to a specific `width`. Maybe you can post an example fiddle, so we can help you directly with your code.
    – Sirko Jul 13 '12 at 15:43
0

Try adding width:100% on your div.

Sirko
  • 72,589
  • 19
  • 149
  • 183
imakeitpretty
  • 2,108
  • 5
  • 16
  • 16