I’m setting top or bottom and left or right values to a few elements. When i’m trying to access this values with Firefox (16.0.2), i get a wrong value for top (a specific value instead of auto)
CSS
div {
bottom:200px;
left:0px;
top:auto;
right:auto;
}
JS
$(function(){
var top = $('div').css('top');
alert(top);
});
You can try it here: http://jsfiddle.net/UEyxD/2/ (works well in Chrome/Safari)
Any ideas how to prevent this? I want to get
This is down to the browser and how it interprets the styles, it is somewhat out of your control. However, with particular CSS and jQuery workarounds you should be able to get around it. For instance, if you do not need to the item to be positioned absolutely then you could remove this, or change it to
position:static;Have a look at this question.