【发布时间】:2016-08-16 11:45:32
【问题描述】:
答案已更新
形成我的研究以在我使用此代码的所有浏览器中获得 AUTO 边距顶部
var bookContainer = $('#book-container');
bookContainer.offset().top
我不知道 Firefox 和 Safari 出了什么问题
它会提示 0px 不正确但 Chrome 和 IE 可以执行正确
使用相同的代码。我想问你知道发生了什么吗??
JS
var bookContainer = $('#book-container');
alert(bookContainer.css('margin-top'))
CSS
#book-container{
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
width: 80%;
max-width: 830px;
max-height: 520px;
/*max-width: 748px;*/
/*max-height: 469px;*/
}
【问题讨论】:
-
您将margin设置为auto,然后如何计算margin-top。
-
@gowtham 我已经更新了我在问题中的答案,还是谢谢你