javascript - Why does jQuery only return integer height if setting a double value clearly renders differently? -


i've got image 924px in height. image has been created appropriate @ height. stretching not desireable.

ontop of image, need overlay variable number of same-height div elements. in particular instance need overlay 88. such, math pretty clear:

924 / 88 = 10.5

each div element must 10.5 pixels in height overlay image.

visually, looks great! have 88 elements , they're 10.5 pixels in height. if set height 11px or 10px see visual differences.

however, using jquery:

$('div').height();  // 10 $('div').css('height'); //10px 

?? huh? they're 10.5 pixels in height, not 10. if dig element's style property -- see 10.5 pixels.

what's going on? can jquery play nice double values height/width? why opposed?

using jquery.height() converts actual amount of pixels taking on screen.

you may find, if iterated through every div on page mixture of height 10's , 11's, since can't render on half pixel, render things take half pixel need decide whether take pixel or not. browser alternate between divs , don't try , best possible result.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -