代码之家  ›  专栏  ›  技术社区  ›  fightstarr20

CSS滚动擦除

  •  -3
  • fightstarr20  · 技术社区  · 6 年前

    我正在尝试像这样实现div scroll wipes example

    有人知道用CSS来实现这一点的方法吗?我一直在研究,但没有找到任何例子。

    视差在滚动吗?

    有人知道他们能给我举什么例子吗?

    1 回复  |  直到 6 年前
        1
  •  0
  •   Andifined    6 年前

    你可以使用粘贴位置:) Browser support

    但这并不是真正的视差滚动。视差效果是“依赖于视图”的,因此前景的移动速度比背景快,并且场景看起来更真实。

    div {
      width: 100vw;
      height: 100vh;
      
      /* This is what you need */
      position: sticky;
      top: 0;
    }
    
    
    div:nth-child(1) {
      background: #ff0000;
    }
    
    
    div:nth-child(2) {
      background: #00ff00;
    }
    
    div:nth-child(3) {
      background: #0000ff;
    }
    <div>1</div>
    <div>2</div>
    <div>3</div>