How do I create a "constrained fixed" div using HTML and JavaScript?

Given the existence of other sections on the page, how do I create a div that acts as if it fixes the width at a specific domain of the web page? Example: Slashdot's commenting system that acts like a fixed-width div for scrolling along the screen, but stays within a certain length? I want a block of text to appear next to the screen for a specific portion of the page, but I want it to stay inside that portion of the page, instead of moving completely along the page as the fixed block will move.

0


source to share


2 answers


Slashdot 's commenting system uses two different types of positioning for this field. When you first visit a page, the margin 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 to the bottom of that column, they switch it to fixed positioning using Javascript.

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

      

+1


source


Do you mean something like



<div style="width xx; height xx; overflow: scroll;">?

      

0


source







All Articles