我與CSS .container { overflow: scroll; }
等下面的HTMLscrollLeft工作,但scrollTop的不工作
<body>
<div class="container">
<div id="markers"></div>
<img id="map" src="/img/map.jpg"/>
</div>
</body>
map.jpg
是非常大的,我想滾動到這樣一個固定的位置:
$(function(){
console.log($('.container').scrollTop());
$('.container').scrollTop(1000);
console.log($('.container').scrollTop());
console.log($('.container').scrollLeft());
$('.container').scrollLeft(1750);
console.log($('.container').scrollLeft());
});
scrollLeft
工作正常,但scrollTop
沒有。以下是控制檯輸出。
0
0
0
1750
我一直在尋找了半個多小時,但仍然不知道如何解決它......
UPDATE: CSS約.container
#markers
和#map
.container { overflow: scroll; width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; padding: 0; }
#map { width: 5000px; max-width: 5000px; height: 2907px; max-height: 2907px; cursor: crosshair; }
#markers { position: relative; top: 0; left: 0; width: 0; height: 0; margin: 0; padding: 0; }
您能否向我們展示更多關於.container,#標記和#map的CSS代碼? – Sybio
@Sybio我已經更新了這個問題。 –
奇怪的是,也許嘗試溢出:自動.container而不是滾動。 – Sybio