views:

87

answers:

2

I have a nested list that lists child nodes when the parent node is expanded. The parent node is expanded by clicking an image to the left of the text.

Unfortunately, it expands right off the page. I would like a scrollbar to appear when the content is off the page.

When I set "overflow: auto", a scrollbar never pops up, it just expands off the page and removes the expansion image on left of the list items.

Here's sample .html:

<body>
  <div id="theDiv" style="clear: left;">
    <ul id="theList">
      <li id="1" class="parent">
       <img class="expanded" align="absmiddle" src="./tree_expanded.gif"/>
        Parent1
         <ul style="display: block;">
           <li id="10">
           .....
         </ul>
      </li>
      ....
    </ul>
  </div>
</body>

Here's sample .js:

function expand() {
  if(this.className == "expand") {
    jQuery(this.parentNode).children("ul").show();
    this.className = "expanded";
    this.src = "/_images/tree_expanded.gif";
  }
 else {
  jQuery("ul", this.parentNode).hide();
  this.className = "expand";
  this.src = "/_images/tree_unexpanded.gif";
 }
}

Here's sample .css:

#theList {
    margin-top: 0;
}

#theList, #theList ul {
    list-style: none;
    margin: 5px 20px;
    padding: 0;
}

#theList .expand, #theList .expanded {
    margin-left: -20px;
    cursor: pointer;
}

#theList img {
    margin-right: 5px;
}

#theList ul {
    display: none;
}

#theList li {
    white-space: nowrap;
    margin-bottom: 4px;
}
A: 

First of all, set a definite width of the container div, so it knows when to start scrolling. Next, set it to overflow-x:scroll; or something to that effect. It should work :)

Salty
A: 

Ok, I was on the right track but not persistent enough. CSS really drives me nuts. I need to set both the div and the list height to get it to scroll. I was trying one or the other, not both.

I'm such a n00b.

Now I have a new problem. Firefox works fine, but ie stopped displaying the images, so it won't expand