我有以下带有 CSS.container { overflow: scroll; }
等的 HTML。
<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
找了半个小时还是不知道怎么解决
更新:.container
#markers
关于和的CSS#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; }