views:

55

answers:

2

I wrote a menu where the total width of the buttons should be always the same width of the menu bar. So i take the whitespace and devide it over the buttons.

It works on: Windows: FF IE6 IE7 IE8 Mac: Safari Chrome

But it doesnt work on Firefox on the Mac can does anyone have an idea?

The example can be found: http://www.bobkarreman.com/menu_prototype/menu/menu.html

EDIT:

The steps i take are:

  • I Calculate the whitespace.
  • Divide that by the number of buttons and round it.
  • Add that together with the current padding to the button.
  • To be sure there are no rounding issues Each time a add the padding to a button i subtract it from the totalWhitespace and on the last LI i add the totalWhitespace.

So it can be that the last LI gets 1 or 2 pixels less or more.

+1  A: 

Well since you're changing the li's widths dynamically their width values are floats rather than integers. It looks to me like the browsers all handle that differently. Try doing the Math.floor function after it's calculated.

tybro0103
I Round the values and because that can cause a rounding issue i subtract the value i add to each li from the whiteSpace and on the last li i add the remaining part. So i dont see how its a float when i add it.
Bob Karreman
A: 

Looking at your console output, it looks like it is not necessarily applying the calculated padding as expected. It seems to be calculating marLeft to 38 (and last to 43) but applying 43 to every <a>. I could be off, I'm only guessing at the meaning of your console output.

It's worth noting also that it's off by a pixel for me in Safari (the last menu's <a> has padding-left: 39px whereas the others have padding-left: 40px, and it is one pixel from the edge of the container).

Edit: I may be misunderstanding your console output, Safari is saying marLeft is 35 but applying 40 (except for last).

Edit 2: I really appreciate there being information in the console to look at. This is the right way to post an example. Thanks!

eyelidlessness
In Safari they are all on One Line and its not off looks like it because of the white right border.
Bob Karreman