Iam wondering if it is a way to force overflow elements of an fixed container to be on the same line instead of going on a new line.
Thank you.
Iam wondering if it is a way to force overflow elements of an fixed container to be on the same line instead of going on a new line.
Thank you.
Yes, there's a way.
You have to replace, float: left
with display: inline-block
, and add white-space: nowrap
to the parent element:
See: http://jsfiddle.net/vrSRE/4/
ul {
width: 300px;
height: 30px;
background: red;
white-space: nowrap
}
li {
display: inline-block
}
If you don't want any space between the elements, the easiest way to fix this new problem is to remove the whitespace in the HTML, like this:
For other options that you probably don't care about to remove the space, see:
And lastly, if you care about IE7 support, use this:
See: http://jsfiddle.net/keBFd/
You can use white-space: nowrap
and display: inline
- you might not want display: inline
, though.