Welcome to WebmasterWorld Guest from

Forum Moderators: not2easy

Message Too Old, No Replies

Position: Fixed - two divs (on inside the other) both fixed

internal one fills the external one



8:33 pm on Apr 14, 2008 (gmt 0)

10+ Year Member

Just to experiment with position fixed, I created a blank page with two divs, each fixed. They basically should be 90% of the size of their container. I put the 2nd div inside the 1st one. That would lead me to believe that the 2nd one would be 90% of the width of the 1st one.

Problem is, the 2nd div is 100% the size of the first one, and it completely covers it up. Am I missing something?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<style type="text/css">

#floatBox {
position: fixed;
top: 1%;
left: 5%;
width: 90%;
height: 90%;
overflow: scroll;
border: 1px solid #003399;

body {
height: 100%;


<p>this is some normal content.</p>

<div class="floatBox"><p>this is some floated content.</p>

<div class="floatBox"><p> this is some more floated content, within the other floated content.</p>



11:58 am on Apr 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

As surprising as it might seem, this is expected behaviour (at least for CSS2.1):

[w3.org ]

Fixed positioning is a subcategory of absolute positioning. The only difference is that for a fixed positioned box, the containing block is established by the viewport.

[edited by: Robin_reala at 11:58 am (utc) on April 15, 2008]


1:17 pm on Apr 15, 2008 (gmt 0)

10+ Year Member

hmph very interesting. can't say I love that but I'll work something out, thanks for the info!


1:56 pm on Apr 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

I'm not quite sure what the behaviour you're expecting from having a fixed box inside a fixed box is. If it's simply for them both to be fixed with respect to the viewport then the inner one doesn't have to be fixed; it'll simply stay inside the fixed parent.


8:28 pm on Apr 18, 2008 (gmt 0)

10+ Year Member

that was just a test, I'm not using it for real

actually what I'm really using is an absolute box within an absolute box that's scrollable. I'd like to update the internal box to be position:fixed so that if the container is scrolled, the internal box still shows up where I want.

since position fixed takes it's size and location from the viewport, that'll be much more difficult


Featured Threads

Hot Threads This Week

Hot Threads This Month