The below code is working fine in chrome but not in firefox. the alert shows proper margin in chrome while in firefox it always shows 0px
.
HTML:
<div class="center">14</div>
CSS:
.center {
margin: 0 auto;
width: 200px;
background-color: #ccc;
}
JQuery: I am using latest jQuery Library
$(function(){
var center = $('.center').css('margin-left');
alert(center);
});
Please see the jsfiddle in both firefox and chrome: http://jsfiddle.net/vtbuz/2/
It's a solution:
var center = $('.center').offset().left;
by using this we can get the proper left position relative to document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With