Overflow:Auto – Height Control with Scrollbars on Page Elements
Many of the web designs my designer creates are very image-heavy. These designs are best fit for websites that wont have loads of content like restaurants, photographers, and graphics designers -- you know, sites where a picture says more than a thousand words. It's important on these types of sites to be able to control the height of the content areas so that the content DIV doesn't grow too high. The way I can do that is by using CSS' overflow property.

The CSS
#content { overflow:auto; height:400px; }
Overflow:Auto allows the customer to place as much content as they'd like within the content area without adversely affecting the page design. While I do everything I can to explain/convince customers that they should prune content and be concise, once the website is in their hands I can't do much about it.
What have you used this type of overflow for? Share!
![CSS 3D Folding Animation]()
Google Plus provides loads of inspiration for front-end developers, especially when it comes to the CSS and JavaScript wonders they create. Last year I duplicated their incredible PhotoStack effect with both MooTools and pure CSS; this time I'm going to duplicate...
![6 Things You Didn’t Know About Firefox OS]()
Firefox OS is all over the tech news and for good reason: Mozilla's finally given web developers the platform that they need to create apps the way they've been creating them for years -- with CSS, HTML, and JavaScript. Firefox OS has been rapidly improving...
![Create a Simple News Scroller Using Dojo]()
My journey into Dojo JavaScript has been exciting and I'm continuing to learn more as I port MooTools scripts to Dojo. My latest experiment is porting a simple new scroller from MooTools to Dojo. The code is very similar!
The HTML
The news items...
![Disable Autocomplete, Autocapitalize, and Autocorrect]()
Mobile and desktop browser vendors do their best to help us not look like idiots by providing us autocomplete, autocorrect, and autocapitalize features. Unfortunately these features can sometimes get in the way; we don't always want or need the help they provide. Luckily most browsers allow...
my solution:
i placed a div at the end of the body content with the follow attributes:
ok – the scrollbar is always showing, not directly at the div element, but it prevents bad “jumping” effects switching between passed size content and overflow content.
I’ve used the overflow to keep a fixed header and footer always visible. Kinda like having frames without using frames. I wanted to keep my options open wrt a footer with ‘ticker tape” content. I needed a “main body content that a user could scroll through.
The correct use of overflow I think, is overflow:auto; so it only adds horizontal bars when needed. overflow:scroll; always adds scrollbars, and I don’t get the point of that.
@Nacho: Thank you for your thoughts and I’ve updated my article. I use “scroll” sometimes because I know the customer will have that much content. After further consideration, you’re suggestion is probably the safer bet..
I use overflow:hidden alot!
overflow:auto; is a life saver for sure!
To clear floats. That’s it.
I dislike scrollable elements within a browser window.
I’m currently using stroller for an online application. The stroller is used specifically for tables contain a lot of data and content after this table is also important and so this way user can view both table and other parts of that page.
@david I have a question.
I’m using scroll for the table content which always have different size of data. So if I set overflow height to lets say
200pxand actual data fills100pxand then there is empty space of100pxunder the table because div overflow is still there but no stroller. Is there a way with JavaScript to set some sort ofmax-heightso if content is not filling200pxthere won’t be any extra space. Sorry if this is confusing, kind of hard to describe without visual example. If you have any thoughts it would be great :-)addition: data is from database and so it can not be predicted the amount of data present there.
“Overflow: auto;” is a good solution for confining content space. But if you’re using animations of any sort (think of a Coda slider), the scrollbars don’t play nice. And scrollbars usually don’t segue with the rest of the content and design.
For aesthetic purposes, when I do control my DIV dimensions and use “overflow: auto;”, I also style the scrollbars (w/Mootools or w/o Moo).
Here’s a Moo CSS-scrollbar script: http://solutoire.com/2008/03/10/mootools-css-styled-scrollbar/
Personally, I style my scrollbars with a non-Moo script, and dynamically load the scrollbar script from my main JS file using Assets.
Or use MooScroll: http://greengeckodesign.com/projects/mooscroll.aspx. =]
how to make the iframe as fully content on the page… i have set height=”100%” but the frame is still in scroll box..
I think we should use
max-height:400px;and notheight:400px;so that if the content-div height is smaller than400pxwe won’t have a huge blank space !!!I love that solution – the only problem is that 3 out of 3 of my ipad browsers don’t support that solution and so dont show a scroller, only a box of text in the size i dtermined :( i guess nothing is perfect
I’ve used the overflow to keep a fixed header and footer always visible