Solved

Absolute Positioning not exact

Posted on 2006-10-31
13
132 Views
Last Modified: 2010-04-09
Or is it me.

I have a blank HTML page.  I wanted a div that took up 10% of the top of the screen and 100% width.

I then wanted 3 divs below this.  Each div went the rest of the height of the screen so 90% and each are to be 33.3% wide.  Well first thing that is wrong is that when I display this page, each of the 3 div's at 30% are not exactly touching, they're both off slightly.  Also the 3 divs are more wide together then the 100% width bar at the top.  Whats the deal with this?  Do percentages not work well?
0
Comment
Question by:cophi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 30

Expert Comment

by:Steggs
ID: 17844298
Greetings cophi,

What browser are you using?


0
 

Author Comment

by:cophi
ID: 17844314
IE 6
0
 

Author Comment

by:cophi
ID: 17844358
I actually tried FIREFOX and it seemed to work fine on that, any reason why it doesn't work properly on IE 6
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 30

Expert Comment

by:Steggs
ID: 17844370
Percentages work fine.

I can tell you now that IE6 will add padding if you do not set padding to 0, also make sure you have margins set to 0. Also, remove whitespace from your html as ie6 will play all kinds of tricks if you give it some whitespace.

Regards
0
 
LVL 17

Expert Comment

by:gops1
ID: 17844401
use css specific to IE

for ex:

.testCss{
       width:33.3%;
}

/* For IE */
* html .testCss{
         width:40%;
}
0
 

Author Comment

by:cophi
ID: 17845467
I have code such as.... <div style="position: absolute; width: 100%; height: 10%; z-index: 1; left: 0px; top: 0px; padding: 0px"

It for some reason just won't work right in IE
0
 
LVL 30

Expert Comment

by:Steggs
ID: 17845524
I wouldnt recommend using positioning for layout. Use floats instead.
0
 

Author Comment

by:cophi
ID: 17849158
ok well i don't understand floats very well.

how would i create 4 divs using floats.  1 div on the top thats 10% height and 100% wide, and then 3 div's underneath that, equally spread, taking up the rest of the screen?
0
 
LVL 16

Expert Comment

by:ThinkPaper
ID: 17853838
show us your code. it will help see what problems you have.
0
 

Author Comment

by:cophi
ID: 17857863
<div style="position: absolute; width: 100%; height: 10%; z-index: 1; left: 0px; top: 0px; padding: 0px" id="1">
<img src="a.JPG" height="100%" width="100%"></div>
<div style="position: absolute; width: 30%; height: 90%; z-index: 2; left: 0px; top: 10%; padding: 0px" id="2">
<img src="b.jpg" height="100%" width="100%"></div>
<div style="position: absolute; width: 40%; height: 90%; z-index: 3; left: 30%; top: 10%; padding: 0px" id="3">
STUFF</div>
<div style="position: absolute; width: 30%; height: 90%; z-index: 5; left: 70%; top: 10%; padding: 0px" id="5">
<img src="c.jpg" height="100%" width="100%"></div>

The renders correctly in Firefox not IE
0
 
LVL 16

Expert Comment

by:ThinkPaper
ID: 18124072
put this in the body.. this will fix the first div

<body topmargin=0 leftmargin=0 rightmargin=0>
0
 
LVL 16

Expert Comment

by:ThinkPaper
ID: 18124139
this was the closest i could come to what you're looking for. I put background colors in it so you can see where it is placed. The only issue is the first div, which has a fixed height... I'll try and see if I can make it completely % based.


<html>
<body topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0>
<div style="position: absolute; width:100%; height: 50px; z-index: 1; left: 0px; top: 0px; padding: 0px;border-color:red;background-color:brown;" id="1">
<img src="a.JPG">top</div>

<div style="position: absolute; width: 30%; height: 93%; z-index: 2; left: 0px; top: 50px; padding: 0px;background-color:gray;" id="2"><img src="b.jpg">x</div>

<div style="position: absolute; width: 40%; height: 93%; z-index: 3; left: 30%; top:50px; padding: 0px;" id="3">STUFF</div>

<div style="position: absolute; width: 30%; height: 93%; z-index: 4; left: 70%; top: 50px; padding: 0px;background-color:gray;" id="5"><img src="c.jpg">x</div>

</body>
</html>
0
 
LVL 16

Accepted Solution

by:
ThinkPaper earned 500 total points
ID: 18124151
ok.. well it seems to work..

<html>
<body topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0>
<div style="position: absolute; width:100%; height: 20%; z-index: 1; left: 0px; top: 0px; padding: 0px;border-color:red;background-color:brown;" id="1">
<img src="a.JPG">top</div>

<div style="position: absolute; width: 30%; height: 80%; z-index: 2; left: 0px; top: 20%; padding: 0px;background-color:gray;" id="2"><img src="b.jpg">x</div>

<div style="position: absolute; width: 40%; height: 80%; z-index: 3; left: 30%; top: 20%; padding: 0px;" id="3">STUFF</div>

<div style="position: absolute; width: 30%; height: 80%; z-index: 4; left: 70%; top: 20%; padding: 0px;background-color:gray;" id="5"><img src="c.jpg">x</div>

</body>
</html>
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question