StuffIKnowAboutComputersAndTheWeb > Scrolling Divs Without Horzontal Scrollbars That Work Across Browsers
Scrolling <div>s are cool. While you could always create scrolling boxes within a page by using an <iframe>, the content of this <iframe> wasn't contained within the page itself, and therefore was invisible to search engines and to any client that didn't support <iframe>s. To both search engines and clients that don't support scrolling <div>s, a scrolling <div> simply appears to be a single, long (or wide, as is your wont) element without any scrolling.
It's common to use a scrolling <div> to contain something like a blogroll, a list of related pages, etc. For these kinds of applications, you want a <div> that has a vertical scrollbar, but not a horizontal scrollbar. While this can be done by restricting the length of content within the <div> to the specified width of the <div>, it's always possible that a user agent will show the content at a larger size than you expect (for instance, because the user has increased font sizes). The below code suppresses the horizontal scrollbar, no matter what:
#notaframe { overflow: auto; overflow-y: scroll; overflow:-moz-scrollbars-vertical; padding: 0px; height: 150px; margin-bottom: 10px; }
This page last modified on January 14, 2006, at 05:30 PM
This work is licensed under a Creative Commons License
