Creating a Scrolling DIV area

  • Digg
  • Technorati
  • del.icio.us
  • Propeller
  • StumbleUpon
  • Reddit
  • Mixx
  • Fark
  • Slashdot
  • Sphinn
  • Design Float
  • DZone
  • BlinkList
  • email
September 6th, 2006 | Web Development How-to's | 0 Comments

At times when creating a site, you may encounter a situation where you need to include more content into DIV than the design is made to handle.

Maybe you want to include the latest news, blogs feeds, or RSS information, but you would like to keep it contained to a small section of the web page.

To do this you can create a scrolling DIV area that will automatically scroll when there is an overflow of content within the DIV. The effect looks much like an iFRAME, but is a far more search engine friendly and user friendly way of doing it.

To do this, start by creating a normal DIV with the content you want to scroll within it.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus augue erat, iaculis nec, pulvinar id, congue non, orci. Mauris cursus pede. Nullam ut mauris. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean ultrices nunc ut est. Integer leo urna, tempor et, congue pellentesque, elementum eget, leo. Fusce ornare. Pellentesque sapien dui, vulputate pretium, dictum sed, accumsan sit amet, ipsum. Nunc commodo libero sit amet odio. Vestibulum eu neque eu felis laoreet posuere. Etiam sed dui in risus porta rutrum. Curabitur eget turpis. Vestibulum sollicitudin tellus sit amet dolor. Cras luctus.

To make the DIV scroll automatically you must use the overflow element in the CSS. Here is what your style sheet would look like for this DIV area:

#exampleDIV {
  border: solid 2px #2895B8;
  background: #dadada;
  color: #666666;
  padding: 4px;
  width: 200px;
  height: 50px;
  text-align: left;
  overflow : auto;
}

By adding the “overflow: auto” to your styles, the DIV will scroll only when there is an overflow of data like this:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus augue erat, iaculis nec, pulvinar id, congue non, orci. Mauris cursus pede. Nullam ut mauris. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean ultrices nunc ut est. Integer leo urna, tempor et, congue pellentesque, elementum eget, leo. Fusce ornare. Pellentesque sapien dui, vulputate pretium, dictum sed, accumsan sit amet, ipsum. Nunc commodo libero sit amet odio. Vestibulum eu neque eu felis laoreet posuere. Etiam sed dui in risus porta rutrum. Curabitur eget turpis. Vestibulum sollicitudin tellus sit amet dolor. Cras luctus.

That’s it! Creating a scrolling DIV is just that easy.

Welcome Back!

Now is your chance to join our growing community! Be the first to know about great new articles like this one. Register for my Email Updates or RSS Feed today!

About the Author

Zach is a marketing consultant and owner of a FL web design and marketing group. He offers graphic design and marketing services, speaks on Internet marketing, and blogs about it all in his free time. (ยป)

Contact Zach: Company Website | Email

Related Posts


Useless Meta Tags

Creating Content That Sells

Security Hole In FireFox A Hoax

Top 100+ Sites for Web Design & Marketing

Center Absolute Position DIV


0 Comments

No comments

RSS feed Comments | TrackBack URI

Write Comment