简体   繁体   中英

Using Anchor Tags to Scroll to

Currently I am using a simple <a name> to scroll; however, there is an issue with the top margins. There is too much space above them, and I'd like the titles to be flesh with the top. I lack javascript and jquery understanding and have researched tirelessly and nothing seems to work for me. Is there is simple solution for this, or a "best method / best practices" to pull this effect off?

    <h2><a style="color: #fff" name="classic">
<div class="menutitle">
<img src="/system/images/W1siZiIsIjIwMTMvMDUvMDEvMTNfMTdfMDNfMjA2X2NsYXNzaWNzLnBuZyJdXQ/classics.png" />
 </div>
</a>
    </h2>



 <div class="large-3 pull-9 columns" style="
position: fixed;
height: 50%;
width: 15%;
 ">

<div class="panel"> 
  <ul class="side-nav">
   <li><div id="appetizer2"><a href="#appetizer"><h3>appetizers</h3></a></div>
 </li>


    <li><div id="soupmenu"><a href="#soup"><h3>soups &amp; side salads</h3> </a>
  </div>
  </li>
    <li><div id="classic"><a href="#classic"><h3>classic</h3></a>

如果您有一个<a href="#mydiv">Jump to My Div</a>类的锚标记和一个<div id="mydiv">的div,则单击该锚将跳至div, div位于页面顶部-除非div位于页面底部附近,在这种情况下,屏幕不会在顶部显示div。

我不太确定您的问题是什么,如果您可以发布一些代码,据我了解您需要滚动页面,则可以使用href =“#someID”或javascript具有内置函数scrollBy(xVal ,yVal)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM