How to make text appear on scroll in html

前端 未结 5 2011

Hello, I want a certain text to appear when I scroll past it or when I scroll until the point where the text is. The effect when appearing should be somewhat like the first effe

5条回答
  •  天涯浪人
    2021-02-02 18:46

    First wrap whatever your text or content that you want to show on scroll, in one div so that you can show hide the div depending upon the scroll. Write two classes for your target div.

    Your CSS:

    /*Use this class when you want your content to be hidden*/
    .BeforeScroll
    {
      height: 100px; /*Whatever you want*/
      width: 100%; /*Whatever you want*/
      .
      .
      display: none;
    }
    
    
    /*Use this class when you want your content to be shown after some scroll*/
    .AfterScroll
    {
      height: 100px; /*Whatever you want*/
      width: 100%; /*Whatever you want*/
      .
      .
      display: block;
    }
    

    Your HTML:

    
    
    
    Content you want to show hide on scroll

    Your Script:

    
    
     
    
    
    

    Hope it will solve your problem.

提交回复
热议问题