如果您在Chrome,FF或IE(8)上測試了網站並調整了窗口大小(高度)中間黃色框內的內容。Safari 6,它不能正確調整大小(滾動條不會停留在底部)
我的問題是,在Safari中,它不能正確調整大小。 (滾動條不停留在div的底部)
HTML:
<body>
<div id="message_box">
<div id="header"> Header </div>
<div id="content">
<ul id="msg_list">
<li>Test file</li>
<li>Test file</li>
<li>Test file</li>
<li>Test file</li> <!-- ...and so on -->
</ul>
</div>
<div id="footer"> Footer </div>
</div>
</body>
CSS:
html, body {
height: 100%;
}
#message_box {
width: 500px;
float: left;
}
#header {
width: 500px;
height: 50px;
background-color: #aaa;
text-align: center;
}
#content {
min-height: 150px;
width: 500px;
position: relative;
background-color: #ffa;
border: solid #cdd1d8;
border-width: 2px 0 2px 0;
overflow-y: scroll !important;
overflow-x: hidden;
}
#msg_list {
width: 100%;
position: absolute;
bottom: 100px;
margin-bottom: 50%;
left: 0;
display: block;
height: 1px;
}
#footer {
height: 300px;
padding: 10px;
background-color: #aaa;
text-align: center;
}
的jQuery (v1.10.1):
$(document).ready(auto_size);
$(window).on("resize", auto_size);
function auto_size() {
var body_content_msg = $("body").height(),
header_content_msg = $("#header").height(),
footer_content_msg = $("#footer").height(),
newHeight = body_content_msg - header_content_msg - footer_content_msg + "px";
$("#content").css("height", newHeight);
}
$(document).ready(function(){
$("#content").scrollTop($("#content")[0].scrollHeight);
});
有人能解釋一下爲什麼這種情況發生在Safari瀏覽器,如何處理?
UPDATE:
你必須調整窗口向上/向下看到「測試文件//第一個消息//」消失在Safari。
這裏是一個Safari 6 bug Test:
... 的Safari 6將進行滾動,而是執行滾動之後,除非你重複調用$ scrollElement.scrollTop將報告不正確的值()。 ...
它在OS X上的Firefox(最新版本)和Safari(最新版本)上看起來是一樣的。這是否發生在PC上的Safari 5中?請記住,Safari for PC已停產,最新版本已超過一年。 – insertusernamehere
@insertusernamehere我在OS X/Safari上測試過6 – aldanux
在OS X/Safari 6.0.2中適用於我的工作正常 – Shivam