Freezing a div within a div

15,673

Solution 1

Add position: relative; to container, and remove floats and add position: fixed; to the block you want to fixate.

Result:

http://jsfiddle.net/nxPhy/1/

Solution 2

You want to add:

position:fixed

to the div that you want fixed. Doing this will position this div and it's containing elements fixed.

Share:
15,673
Amit
Author by

Amit

Updated on June 04, 2022

Comments

  • Amit
    Amit almost 2 years

    My basic layout is a couple of divs within a div - http://jsfiddle.net/nxPhy/ - I'm looking for a css way to have the const div always visible regardless of any horizontal scrolling of the parent div (so only the content div is actually scrolled).