1

http://jsfiddle.net/XRXNv/

Exact height is 18.4 px when watching by browser, jquery is giving 18

How to fix this

http://jsfiddle.net/XRXNv/1/

In this second jsfiddle I want to set the viewport height to the sum of first 8 li-s, and there is a little problem...

IE is giving 144, mozilla 172, chrome 160 :)

ArmeniaH
  • 733
  • 1
  • 8
  • 18

3 Answers3

2

The reason that you receive different heights in different browsers is not pixel rounding issues, it is because the default rendering styles are different between different browsers.

If you want the exact same height across all browsers, style the list to set a height manually. And while you're at it, set it to an integer.

David Hedlund
  • 128,221
  • 31
  • 203
  • 222
1

You can't set decimal values in pixels:

can an element have a a decimal height in html/css?

If you take a look at the computed style in the javascript console, you'll see that the height is 18px

Community
  • 1
  • 1
davids
  • 6,259
  • 3
  • 29
  • 50
0

I don't think you are suposed to use decimal numbers. The jQuery transforms the number into and int. And not a double or float. I recommend sticking to whole numbers :)

Gogoro
  • 31
  • 4