滚动行为完全不起作用 [英] scroll behaviour smooth not working at all

查看:47
本文介绍了滚动行为完全不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道为什么我的滚动平滑根本不起作用.我不太清楚为什么?我想添加 overflow-y:滚动;滚动行为:平滑; 会有所帮助,但无法正常工作.这是我的代码:

I am wondering why my scroll smooth isn't working at all. I am not too sure why? I thought adding overflow-y: scroll; scroll-behavior: smooth; will help but its not working. Here is my code:

#container{
    overflow-y: scroll;
    scroll-behavior: smooth;
}
.topTab{
bottom: 0;
position: fixed;
font-size: 25px;
color: white;
}
.pg{
  font-size: 100px;
  height: 100vh;
  background-color: blue;
  text-align: center;
}

a{
 color: white;
}

<div class = "topTab">
  <li><a href="#1">1</a></li>
  <li><a href="#2">2</a></li>
  <li><a href="#3">3</a></li>
</div>

<div id = "container">
<div id = "1" class= "pg">1</div>
<div id = "2" class = "pg">2</div>
<div id = "3" class = "pg">3</div>
</div>

推荐答案

  • 尝试这个...
  • html {
      scroll-behavior: smooth;
    }
    
    #container{
        overflow-y: scroll;
    }
    .topTab{
    bottom: 0;
    position: fixed;
    font-size: 25px;
    color: white;
    }
    .pg{
      font-size: 100px;
      height: 100vh;
      background-color: blue;
      text-align: center;
    }
    
    a{
     color: white;
    }

    <div class = "topTab">
      <li><a href="#1">1</a></li>
      <li><a href="#2">2</a></li>
      <li><a href="#3">3</a></li>
    </div>
    
    <div id = "container">
    <div id = "1" class= "pg">1</div>
    <div id = "2" class = "pg">2</div>
    <div id = "3" class = "pg">3</div>
    </div>

    这篇关于滚动行为完全不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆