http://www.webmasterworld.com Welcome to WebmasterWorld Guest from 38.103.63.17
register, login, search, glossary, subscribe, help, library, PubCon, announcements , recent posts, unanswered posts
Subscribe to WebmasterWorld
Home / Forums Index / Browser Side World / CSS
Forum Library : Charter : Moderators: DrDoc & Robin reala & SuzyUK

CSS

  
Position: Fixed - two divs (on inside the other) both fixed
internal one fills the external one
Mike521


#:3626716
 8:33 pm on April 14, 2008 (utc 0)

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">
<html>
<head>
<style type="text/css">

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

body {
height: 100%;
}

</style>
</head>
<body>

<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>
</div>
</div>

</body>
</html>

Robin_reala


#:3627271
 11:58 am on April 15, 2008 (utc 0)

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

http://www.w3.org/TR/CSS21/visuren.html#fixed-positioning

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]

Mike521


#:3627316
 1:17 pm on April 15, 2008 (utc 0)

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

Robin_reala


#:3627352
 1:56 pm on April 15, 2008 (utc 0)

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.

Mike521


#:3630185
 8:28 pm on April 18, 2008 (utc 0)

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

 

Home / Forums Index / Browser Side World / CSS
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
WebmasterWorld ® and PubCon ® are a Registered Trademarks of WebmasterWorld Inc.
© WebmasterWorld Inc. / SearchEngineWorld 1996-2008 all rights reserved