views:

975

answers:

2

Given the existence of other divs on a page, how would one create a div that acts as if it's fixed-width within a certain domain of a web page? Example: the commenting system on Slashdot, which acts like a fixed-width div for purposes of scrolling along a screen but will remain within a certain length? I want a block of text to appear alongside the screen for a certain part of the page, but I want it to stay within that piece of the page, rather than have it move entirely along the page like a fixed block would move.

A: 

Do you mean something like

<div style="width xx; height xx; overflow: scroll;">?
Marcin Gil
+1  A: 

Slashdot's commenting system uses two different types of positioning for that box. When you first come to the page, the box is absolutely positioned so that it appears at the bottom of that column on the left. (CSS code here:)

left: 0px;
top: 429px; /* or something */
position: absolute;

When you scroll down below the bottom of that column they switch it to fixed positioning using Javascript.

left: 0px;
top: 0px;
position: fixed;
Nate Cook