Amit
Amit

Reputation: 1184

Freezing a div within a div

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).

Upvotes: 3

Views: 22541

Answers (2)

sidneydobber
sidneydobber

Reputation: 2910

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.

Upvotes: 1

lorenzo-s
lorenzo-s

Reputation: 17010

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/

Upvotes: 3

Related Questions