Home  >  Q&A  >  body text

scroll offsethtml

<p>I'm trying to do something in HTML and CSS but not sure if it actually works. </p> <p>I want to make sure I add some kind of "delay" when scrolling, like slowing down the scrolling to make it softer. </p> <p>Some sites do do this, I have visited some pages that scrolled differently than other sites and looked soft. </p> <p>Is this possible? </p>
P粉205475538P粉205475538451 days ago477

reply all(1)I'll reply

  • P粉868586032

    P粉8685860322023-08-18 10:44:43

    sure! To achieve a smooth scrolling effect on your website, you can use the following CSS rules:

    html {
      scroll-behavior: smooth;
    }

    To create internal links that trigger smooth scrolling, use anchor tags like this in your HTML:

    <a href="#section1">跳转到第一部分</a>
    <a href="#section2">跳转到第二部分</a>
    
    <section id="section1">
      <!-- 第一部分的内容 -->
    </section>
    
    <section id="section2">
      <!-- 第二部分的内容 -->
    </section>

    By using this method, your website scrolling will feel smoother and more comfortable for users.

    reply
    0
  • Cancelreply