CSS Attach container and overflow elements
source link: https://www.codesd.com/item/css-attach-container-and-overflow-elements.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
CSS Attach container and overflow elements
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:
- How to remove the space between inline-block elements?
And lastly, if you care about IE7 support, use this:
Related Articles
CSS left float and position elements
Applying CSS to Label and Input Elements Using Values in jQuery
CSS float: left and overflow: visible section of the text
How to align two divs side by side using floating, clear and overflowing elements with a fixed position div /
CSS: vertical centering and overflow content
Fluid arrangement Css with fixed and reactive elements
Problem with overlapping and overflowing elements
Hide a container and show another
Why Overflow: Hidden widens the parent element (containing floating child elements)?
CSS first child and last child do not work when used on the same element
When a Flexbox element has a packaging text, the element fills the container and has an extra white space at the end
Use an image name contained in an element - XML / CSS
How can I use CSS to select and classify all LI elements that have UL sub-elements?
Attach a header to the top of a container with overflow: Automatic;
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK