Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    54
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Getting proper height for div

    I have an absolutely positioned element (image) at the very bottom of the page which is about 20px in height using this css:
    #bottomdiv {
    position:absolute;
    bottom:0;
    }

    Now, i want another div to extend from *nearly* the top of the page to right above the absolutely positioned element. I cannot set this div height in px as i am trying to make it resolution independent.

    I did this by setting the following css rule to the element:
    #mydiv {
    position:absolute;
    top:5%;
    bottom:10pt;
    border:1px solid #333333;
    }
    but it does not work in IE6!

    How can i make this work?

    Thanks in advance!
    raghu207

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello raghu207,
    Does this work?
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    html, body {
    	background: #CCCCCC;
    	height: 100%;
    }
    * {
    	margin: 0;
    	padding: 0;
    	border: none;
    }
    #mydiv {
    	position:absolute;
    	top:5%;
    	height: 85%;
    	width: 100%;
    	background: #00FF00;
    }
    #bottomdiv {
    	position:absolute;
    	bottom:0;
    	height: 10%;
    	width: 100%;
    	background: #FF9999;
    }
    
    </style>
    </head>
    <body>
    	<div id="mydiv"></div>
        <div id="bottomdiv"></div>
    </body>
    </html>
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • Users who have thanked Excavator for this post:

    raghu207 (01-12-2008)

  • #3
    New Coder
    Join Date
    Aug 2006
    Posts
    54
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks, it worked!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •