CSS
-Tricks
treehouse :
what would you like to learn today?
Web Design
Web Development
iOS Development
Show search box
Search
Search in:
All
Articles
Forums
Snippets
Videos
✕
Home
Forums
Snippets
Gallery
Videos
Almanac
Demos
Lodge
Navigation 'n' Search
Forums
Illustration by Nick Sirotich
Forums
»
CSS Combat
Position div fixed relative to parent?
iceangel89
Permalink to comment
#
July 2009
i seem to notice that position: fixed is relative to whole body/html. can i position an element fixed relative to an element?
markup is something like
<div id=\"wrapper\">
<div id=\"main\" />
<div id=\"sidebar\" />
</div>
wrapper is centered
i want to position sidebar fixed relative to the wrapper/current position. so scrolling will only affect div#main
Robskiwarrior
Permalink to comment
#
July 2009
nope - fixed is always relative to the browser window :)
If you want to do it inside a box, use absolute - but then it will scroll with teh box... lol
Add a Comment
markup is something like
wrapper is centered
i want to position sidebar fixed relative to the wrapper/current position. so scrolling will only affect div#main
If you want to do it inside a box, use absolute - but then it will scroll with teh box... lol