• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 34047
  • Last Modified:

td with div scroll with height 100%

I know this problem had been spoken before but the solution didn't help me.
My problem: I have a td with sometimes a lot of text but this td may only take the entire screen. If the text is longer than the entire screen, the td needs a scroll bar, but only the td, not whole the page. I hope I'm being clear.

The solution I have read on this forum:
in your stylesheet:
#scroll {height:100%;

and in your document:
<div id="scroll">here text</div>

But this doesn't helps.

thanks in advance for any help
3 Solutions
Have you assigned the height/width for your enclosing elements?

<body style="height:100%;width:100%;">
  <div style="height:100%;overflow:auto;">Multiple lines</div>

/ /a code which i'd picked from this forum
<TABLE BORDER=1 HEIGHT=100><TR><TD>No Scroll.</TD><TD>No Scroll.</TD><TD WIDTH=80>
<DIV STYLE="overflow:scroll;width:100%;height:100%">This can scroll!<P>See?<P>There is more text here.</DIV>
To get scrolling in a cell you have to fix the format of the table and give the div in cell an explicit height.  Height 100% will not work for many browsers so you have to set the height dynamically at load time.  The initial shor height is required to prevent the table from oversizing before the calculation and messing things up.  You need to use the strict doctype.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<style type="text/css">
#thetable {border:1px solid blue;width:100%; table-layout:fixed; }
#thecell {overflow:auto;clip:auto;border:1px solid black; width:100%;height:60px }
<script type="text/javascript">
   function setH()
      if (document.documentElement && document.documentElement.clientHeight)
<table id="thetable">
    <td> DATA </td>
    <div id="thecell">
    Lorem ipsum dolor sit amet, lacus nonummy tempus, dui nascetur. Sociosqu luctus habitasse. Tempus dictumst curabitur sit id malesuada ipsum, at facilisi dignissim. Hendrerit potenti. Convallis nam. Cursus inceptos risus pretium nec aliquam nascetur. Ultricies vivamus eros congue conubia bibendum magnis nullam malesuada nam ultrices placerat iaculis.
Blandit eu nunc egestas sociosqu cubilia sagittis a mollis nascetur. Nisl euismod curae vivamus. Eleifend fermentum erat. Tempus semper hymenaeos scelerisque massa, purus cursus mus sociis libero. Eu fermentum sodales. Integer ac vestibulum wisi facilisis consequat, vitae mattis enim donec. Molestie orci.
A dictumst sollicitudin quam habitasse integer netus scelerisque neque orci. Luctus hendrerit quam tempus iaculis praesent tempor per, sociosqu sollicitudin dictum bibendum. Nisl neque ornare viverra ultricies parturient cursus rhoncus inceptos mauris cursus vivamus faucibus. In orci class quis. Conubia condimentum sollicitudin scelerisque varius platea vivamus adipiscing, purus viverra. Nullam nisl elit est quis. Et, diam orci neque ultrices erat.
Habitant pretium. Suscipit ante. Volutpat suscipit odio. Nostra nunc ultrices eleifend egestas cursus. Diam cursus enim habitasse sed, sociis et. Sit interdum mi ridiculus pretium id, senectus tincidunt aenean sem pulvinar pellentesque. Et libero.    
    <td > DATA </td>
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now