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
Solved

Absolute Positioning not exact

Posted on 2006-10-31
13
128 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
  • 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

856 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