HighDots Forums  

Firefox en Opera: 1 pixel gap between 2 div blocks with width set to 50%

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Firefox en Opera: 1 pixel gap between 2 div blocks with width set to 50% in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Veerle
 
Posts: n/a

Default Firefox en Opera: 1 pixel gap between 2 div blocks with width set to 50% - 10-28-2005 , 09:10 AM






Hi,

I have 2 div blocks with each div taking up half of the page width. So
in the CSS they both have width: 50%. See
http://home.scarlet.be/~vv991306/leftright.html

In Mozilla Firefox and Opera, depending on the width of the browser
window, sometimes there is a 1 pixel gap between the 2 div blocks. In
Internet Explorer, this is never the case.

I think I know why the gap is sometimes there: Firefox and Opera
probably calculate the width of 1 div block as page width divided by 2.
If the page width is an even number, then the sum of the 2 widths
equals to the page width. But if the page width is an odd number then
the sum of the 2 widths + 1px = page width. This probably is the reason
for the 1 pixel gap.

The question is: anyone knows of a way to avoid this problem? I find
setting both one of the div widths to 51% not a nice solution, because
I want my two blocks to have equal widths and 51% makes quite a big
difference.

Any ideas?

Veerle


Reply With Quote
  #2  
Old   
Els
 
Posts: n/a

Default Re: Firefox en Opera: 1 pixel gap between 2 div blocks with width set to 50% - 10-28-2005 , 09:48 AM






Veerle wrote:

Quote:
Hi,

I have 2 div blocks with each div taking up half of the page width. So
in the CSS they both have width: 50%. See
http://home.scarlet.be/~vv991306/leftright.html

In Mozilla Firefox and Opera, depending on the width of the browser
window, sometimes there is a 1 pixel gap between the 2 div blocks. In
Internet Explorer, this is never the case.

I think I know why the gap is sometimes there: Firefox and Opera
probably calculate the width of 1 div block as page width divided by 2.
If the page width is an even number, then the sum of the 2 widths
equals to the page width. But if the page width is an odd number then
the sum of the 2 widths + 1px = page width. This probably is the reason
for the 1 pixel gap.

The question is: anyone knows of a way to avoid this problem? I find
setting both one of the div widths to 51% not a nice solution, because
I want my two blocks to have equal widths and 51% makes quite a big
difference.

Any ideas?
You'll have to play with it a little, but I've noticed that it makes a
difference to set the width to auto and define the margin in
percentage, or vice versa. Maybe setting each div to auto and the
respective right or left margin to 50% does the trick. (maybe not)

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.