使用CSS实现阅读进度条


Posted in HTML / CSS onFebruary 27, 2017

不用JavaScript也能实现阅读进度条

看图说话

使用CSS实现阅读进度条

直接上代码

<style>
        html,body{margin:0;}
        header{
            position: fixed;
            top:0;
            height: 125px;
            width: 100%;
            background: white;
        }
        main{
            margin-top: 128px;
        }
        @supports (height: 100vh) { 
            body{   
                background: linear-gradient(to right top, #0089f2 50%, #DDD 50%);
                background-size: 100% calc(100% - 100vh + 129px);
                background-repeat: no-repeat;
            }
            body:before{
                content:'';
                position: fixed;
                top: 128px;
                bottom: 0;
                width: 100%;
                z-index: -1;
                background: white;
            }
        }
     </style>
    <header>
        <h1>Scroll Indicator</h1>
    </header>
    <main>
        <h2>I was interested to see if I could make a scroll indicator  with just CSS.</h2>
        <p>You can! But maybe you shouldn't. This is an interesting consequence of a bunch of hacks held together with duct tape. It uses z-index hacks, gradient hacks and tricks with calc and viewport units.</p>
        <p>Having said that, hacks are not always bad. I love hacks and many of us have made quite a good living selling floats and clearfixes.</p>
        <p>The techniques used here are well supported, if not conventional. If you can read the CSS, understand how it works, and how to change it, and you think this works better for you than JavaScript, feel free to implement it. Just be aware of the z-index behaviour and possible conflict with other CSS using negative z-index.</p>
        <hr>
        <p>Cras mattis consectetur purus sit amet fermentum. Donec id elit non mi porta gravida at eget metus. Donec id elit non mi porta gravida at eget metus. Aenean lacinia bibendum nulla sed consectetur.</p>
        <h3>Tristique Aenean Etiam Cras</h3>
        <p>Donec id elit non mi porta gravida at eget metus. Donec ullamcorper nulla non metus auctor fringilla. Nulla vitae elit libero, a pharetra augue. Donec sed odio dui. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>
        <p>Cras mattis consectetur purus sit amet fermentum. Donec id elit non mi porta gravida at eget metus. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Etiam porta sem malesuada magna mollis euismod. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec ullamcorper nulla non metus auctor fringilla.</p>
        <p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Donec ullamcorper nulla non metus auctor fringilla. Sed posuere consectetur est at lobortis. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Aenean lacinia bibendum nulla sed consectetur. Nulla vitae elit libero, a pharetra augue.</p>
        <p>Donec sed odio dui. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Cras mattis consectetur purus sit amet fermentum. Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
        <ul>
            <li>Ullamcorper Aenean Ornare</li>
            <li>Ridiculus Lorem Malesuada Consectetur</li>
            <li>Aenean Tristique Sit Lorem Purus</li>
            <li>Vehicula Egestas Mollis Cursus Nibh</li>
        </ul>
        <p>Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Sed posuere consectetur est at lobortis. Sed posuere consectetur est at lobortis. Maecenas faucibus mollis interdum. Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean lacinia bibendum nulla sed consectetur. Nullam quis risus eget urna mollis ornare vel eu leo.</p>
        <h3>Bibendum Aenean Dapibus Tristique</h3>
        <p>Cras mattis consectetur purus sit amet fermentum. Donec id elit non mi porta gravida at eget metus. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Etiam porta sem malesuada magna mollis euismod. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec ullamcorper nulla non metus auctor fringilla.</p>
        <p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Donec ullamcorper nulla non metus auctor fringilla. Sed posuere consectetur est at lobortis. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Aenean lacinia bibendum nulla sed consectetur. Nulla vitae elit libero, a pharetra augue.</p>
        <p>Donec sed odio dui. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Cras mattis consectetur purus sit amet fermentum. Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
        <ul>
            <li>Ullamcorper Aenean Ornare</li>
            <li>Ridiculus Lorem Malesuada Consectetur</li>
            <li>Aenean Tristique Sit Lorem Purus</li>
            <li>Vehicula Egestas Mollis Cursus Nibh</li>
        </ul>
        <p>Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Sed posuere consectetur est at lobortis. Sed posuere consectetur est at lobortis. Maecenas faucibus mollis interdum. Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean lacinia bibendum nulla sed consectetur. Nullam quis risus eget urna mollis ornare vel eu leo.</p>
        <h2>Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</h2>
        <p>Cras mattis consectetur purus sit amet fermentum. Donec id elit non mi porta gravida at eget metus. Donec id elit non mi porta gravida at eget metus. Aenean lacinia bibendum nulla sed consectetur.</p>
    </main>

以上所述是小编给大家介绍的使用CSS实现阅读进度条,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对三水点靠木网站的支持!

HTML / CSS 相关文章推荐
IE滤镜与CSS3效果(详细整理分享)
Jan 25 HTML / CSS
CSS3+font字体文件实现圆形半透明菜单具体步骤(图解)
Jun 03 HTML / CSS
推荐10个CSS3 制作的创意下拉菜单效果
Feb 11 HTML / CSS
Css3圆角边框制作代码
Nov 18 HTML / CSS
深入浅析css3 中display box使用方法
Nov 25 HTML / CSS
使用CSS3实现SVG路径描边动画效果入门教程
Oct 21 HTML / CSS
移动web模拟客户端实现多方框输入密码效果【附代码】
Mar 25 HTML / CSS
html5 canvas实现跟随鼠标旋转的箭头
Mar 11 HTML / CSS
html5中为audio标签增加停止按钮动作实现方法
Jan 04 HTML / CSS
html5桌面通知(Web Notifications)实例解析
Jul 07 HTML / CSS
html5实现九宫格抽奖可固定抽中某项奖品
Jun 15 HTML / CSS
Html5饼图绘制实现统计图的方法
Aug 05 HTML / CSS
利用css3 translate完美实现表头固定效果
Feb 28 #HTML / CSS
纯CSS3实现Material Design效果
Mar 09 #HTML / CSS
CSS3实现精美横向滚动菜单按钮
Apr 14 #HTML / CSS
真正了解CSS3背景下的@font face规则
May 04 #HTML / CSS
手把手教你用纯css3实现轮播图效果实例
May 04 #HTML / CSS
使用HTML5和CSS3表单验证功能
May 05 #HTML / CSS
CSS3实现任意图片lowpoly动画效果实例
May 11 #HTML / CSS
You might like
一些常用的php简单命令代码集锦
2007/09/24 PHP
PHP 操作文件的一些FAQ总结
2009/02/12 PHP
PHP积分兑换接口实例
2015/02/09 PHP
详解Laravel设置多态关系模型别名的方式
2019/10/17 PHP
jQuery源码分析之Event事件分析
2010/06/07 Javascript
html+css+js实现xp window界面及有关功能
2013/03/26 Javascript
关于extjs treepanel复选框选中父节点与子节点的问题
2013/04/02 Javascript
javascript实现依次输入input自动定焦
2014/12/23 Javascript
div实现自适应高度的textarea实现angular双向绑定
2017/01/08 Javascript
angularjs使用directive实现分页组件的示例
2017/02/07 Javascript
微信小程序 PHP生成带参数二维码
2017/02/21 Javascript
安装vue-cli报错 -4058 的解决方法
2017/10/19 Javascript
jquery操作checkbox的常用方法总结【附测试源码下载】
2019/06/10 jQuery
浅析vue-router中params和query的区别
2019/12/24 Javascript
vue实现户籍管理系统
2020/05/29 Javascript
详细分析JavaScript中的深浅拷贝
2020/09/17 Javascript
python实现比较两段文本不同之处的方法
2015/05/30 Python
Djang中静态文件配置方法
2015/07/30 Python
python书籍信息爬虫实例
2018/03/19 Python
python实现决策树、随机森林的简单原理
2018/03/26 Python
Numpy数据类型转换astype,dtype的方法
2018/06/09 Python
python3爬虫怎样构建请求header
2018/12/23 Python
pycharm远程开发项目的实现步骤
2019/01/20 Python
Python3利用Dlib实现摄像头实时人脸检测和平铺显示示例
2019/02/21 Python
Python字符串的常见操作实例小结
2019/04/08 Python
Python 静态方法和类方法实例分析
2019/11/21 Python
Tensorflow tf.dynamic_partition矩阵拆分示例(Python3)
2020/02/07 Python
Python爬取YY评级分数并保存数据实现过程解析
2020/06/01 Python
使用CSS3的box-sizing属性解决div宽高被内边距撑开的问题
2016/06/28 HTML / CSS
TheFork葡萄牙:欧洲领先的在线餐厅预订平台
2019/05/27 全球购物
“学雷锋活动月”总结
2014/03/09 职场文书
领导班子遵守党的政治纪律情况对照检查材料
2014/09/26 职场文书
公安机关纪律作风整顿剖析
2014/10/10 职场文书
淘宝客服专员岗位职责
2015/04/07 职场文书
销售员岗位职责范本
2015/04/11 职场文书
幼儿园安全教育月活动总结
2015/05/08 职场文书