homepage Welcome to WebmasterWorld Guest from 54.242.126.126
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

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

10+ Year Member



 
Msg#: 3626714 posted 8:33 pm on Apr 14, 2008 (gmt 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

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3626714 posted 11:58 am on Apr 15, 2008 (gmt 0)

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]

Mike521

10+ Year Member



 
Msg#: 3626714 posted 1:17 pm on Apr 15, 2008 (gmt 0)

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

Robin_reala

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3626714 posted 1:56 pm on Apr 15, 2008 (gmt 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

10+ Year Member



 
Msg#: 3626714 posted 8:28 pm on Apr 18, 2008 (gmt 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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved