【问题标题】:Setting default scroll point on <div>在 <div> 上设置默认滚动点
【发布时间】:2013-07-19 21:25:36
【问题描述】:

我有

.scroller {
    font-family : Arial,Sans-Serif;
    background : white;
    overflow-y : scroll;
    font-size  : 9.5pt; /* needed for scrollers w/o tables */
    }   

我后来申请的

<div class="scroller">
   ... lots of content here ...
</div>

默认显示滚动条内容的顶部。我想滑到中间的某个地方。

【问题讨论】:

    标签: css html scroll scrollview


    【解决方案1】:

    假设你的内容是这样的:

    <div class="scroller">
       <div id="1">
          ... lots of content here ...
       </div>
       <div id="2">
          ... lots of content here ...
       </div>
    </div>
    

    使用它滚动到&lt;div id="2"&gt;:

    $("div.scroller").scrollTop($("#2").offset().top);
    

    看一个例子:Fiddle Demo。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-06
      • 1970-01-01
      • 1970-01-01
      • 2012-01-21
      相关资源
      最近更新 更多