• 滚动轴 scroll


        css中的scroll,我们最先想到的应该是overflow:scroll。

    控制滚动轴的7个伪元素分别是:

        

    ::-webkit-scrollbar:整个滚动条
    ::-webkit-scrollbar-button:滚动条上的按钮(下下箭头)
    ::-webkit-scrollbar-thumb:滚动条上的滚动滑块
    ::-webkit-scrollbar-track:滚动条轨道
    ::-webkit-scrollbar-track-piece:滚动条没有滑块的轨道部分
    ::-webkit-scrollbar-corner:当同时有垂直和水平滚动条时交汇的部分
    ::-webkit-resizer:某些元素的交汇部分的部分样式(类似textarea的可拖动按钮)
    

      

    二、scroll-behavior

    有如下2个属性

    /* Keyword values */
    scroll-behavior: auto;
    scroll-behavior: smooth;

    有了这个属性,可以让我们的滚动更加平滑。

    例如,原来的返回到顶部还要用js实现,现在仅仅用css就可以实现,代码如下:

    <a href="#">返回顶部</a>
    
    html, body { scroll-behavior:smooth; }

    我们可以直接在html,或者body中添加如下:

    html, body { scroll-behavior:smooth; }

    类似把这段代码放到base.css中,凡是支持这个属性的,都会自动加上平滑滚动的效果。

    纯css的tab切换,加上了scroll-behavior:smooth;

    三、Scroll Snap

    CSS Scroll Snap是CSS中一个独立的模块,可以让网页容器滚动停止的时候,自动平滑定位到指定元素的指定位置,包含scroll-以及scroll-snap-等诸多CSS属性。

    /* Keyword values */
    scroll-snap-type: none;
    scroll-snap-type: x;
    scroll-snap-type: y;
    scroll-snap-type: block;
    scroll-snap-type: inline;
    scroll-snap-type: both;
    
    /* Optional mandatory | proximity*/
    scroll-snap-type: x mandatory;
    scroll-snap-type: y proximity;
    scroll-snap-type: both mandatory;
  • 相关阅读:
    Tomcat 性能优化
    Centos下Tomcat 安装Apache Portable Runtime
    单机多实例Tomcat部署
    Maven 常用命令, 备忘
    IntelliJ IDEA运行tomcat项目编码错误, 及如何指定tomcat编码
    多个mapper location时, mybatis spring的自动扫描配置
    X200s,Debian 8(Jessie) 安装流水帐
    dubbo2.5.3 与spring 3.1.x 冲突
    IntelliJ Idea14 创建Maven多模块项目
    为EXSi5.5上的Centos虚机增加硬盘容量
  • 原文地址:https://www.cnblogs.com/muouran/p/13876561.html
Copyright © 2020-2023  润新知