Forum Moderators: not2easy

Message Too Old, No Replies

overflow scroll will scroll right and down, not up or left

         

peterm

7:16 pm on Apr 29, 2008 (gmt 0)

10+ Year Member



Hi

I have a large div with overflow:auto, and javascript that places nested divs and moves them around inside this div. I would like for the div to allow me to scroll and see any of the nested divs if they move too far in any direction.

Currently the scroll bars handle everything fine if one of the nested divs moves past the right or bottom borders of the main div, but simply hides them if they move past the top or left borders.

Any ideas how to get it to allow me to scroll left or up from the starting position?

Here is some example code that avoids javascript but should give an idea of what I want. I'd like to be able to scroll to read all of the text on this page:


[pre]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>scroll test</title>
<style type="text/css">
div.container {
border:1px solid;
height:100px;
width:200px;
position:fixed;
left:200px;
top:200px;
overflow:scroll;
}
p {
margin:-10px;
white-space:nowrap;
}
</style>
</head>
<body>
<div class="container">
<p>
This is some text.<br>
It has multiple<br>
lines. This line is long enough for a right-scroll.<br>
</p>
</div>
</body>
[/pre]

any help you could offer would be much appreciated.
Thanks,
Peter

JAB Creations

8:21 am on Apr 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Peter and welcome to WebmasterWorld!

I have witnessed this before however in my experience this is simply a sign that we are attempting to achieve a goal using the standards out of context.

I'm not sure what your related goal is? Could you please clarify how this relates to something you have not posted? Or is this simply an oddity you're curious about?

- John

peterm

8:18 pm on Apr 30, 2008 (gmt 0)

10+ Year Member



Hi John,
Thanks for the followup.
I'm working on a site that does network layout using javascript. Essentially, there's one static div in the middle of the page, and a bunch of other mobile divs attached to it. I'm using the jsViz library to dynamically move everything with simulated repulsive forces between each div and a spring force between connected springs. Essentially, there are up to 20 divs that dynamically decide their position.
Often, the layout wants to push the divs over the edge of the window, and I would like them to be able to do so. There is logic in the script that can stop them at the edge, but then they bunch up. By setting overflow:auto in the body element the divs can fall off the right side and bottom side just fine, with scroll bars appearing to go see where they went. The top and left sides, however, just let the divs go with no way to scroll and see them.
(I'm asking this in CSS forum rather than javascript forum because I think at it's heart it's a layout issue that's just being triggered by javascript).

Essentially:
Is there any way to have the content of the window expand upward or to the left (after page load) without becoming completely inaccessible? It seems like this is what the overflow property is supposed to handle, but it only seems to handle it in two of four directions.
(there are probably huge javascript solutions to this, but I'd like to avoid adding more heavy scripting in an already script-heavy site.)

Thanks!
Peter

JAB Creations

7:29 am on May 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Peter,

Set the divisible element to overflow: scroll; then, I've never encountered a situation where you don't get horizontal scrollbars. It does not mean it will become scrollable to the left or the top however. It seems to me that sort of desired behavior needs to be programmed via JavaScript to enable you to scroll left/upwards further then the browser default.

- John