设为首页 加入收藏

TOP

博客园美化阅读模式(一)
2019-10-09 20:01:27 】 浏览:90
Tags:博客 美化 阅读 模式

为了自己能更加好的查看自己的总结以及让关注我的小可爱们能更加好的学习我弄了阅读模式

一.直接上代码

放在页脚即可

<!--阅读模式-->
<style>
    .read_book {
        background: url(https://images.cnblogs.com/cnblogs_com/pythonywy/1516412/o_greedread.png)
    }

    .not_read_book {
        background: url(https://images.cnblogs.com/cnblogs_com/pythonywy/1516412/o_notread.png)
    }

    .read_book_button {
        height: 38px;
        width: 38px;
        border-radius: 50%;
        border: none;
        position: fixed;
        bottom: 22px;
        left: 20px;
        outline: none;
    }

    .read_goend_button {
        background: url(https://images.cnblogs.com/cnblogs_com/pythonywy/1516412/o_goend2.png);
        height: 38px;
        width: 38px;
        border-radius: 50%;
        border: none;
        position: fixed;
        bottom: 67px;
        left: 20px;
        outline: none;
    }

    .read_gotop_button {
        background: url(https://images.cnblogs.com/cnblogs_com/pythonywy/1516412/o_gotop.png);
        height: 38px;
        width: 38px;
        border-radius: 50%;
        border: none;
        position: fixed;
        bottom: 112px;
        left: 20px;
        outline: none;
    }

    .read_auto_button {
        height: 38px;
        width: 38px;
        border-radius: 50%;
        border: none;
        position: fixed;
        bottom: 156px;
        left: 20px;
        outline: none;
    }
    .start_auto{
        background: url(https://images.cnblogs.com/cnblogs_com/pythonywy/1516412/o_auto_start.png);
    }
    .stop_auto{
        background: url(https://images.cnblogs.com/cnblogs_com/pythonywy/1516412/o_auto_stop.png);
    }
</style>


<button class="read_auto_button start_auto" style="display: none"></button>
<button class="read_gotop_button" style="display: none"></button>
<button class="read_goend_button" style="display: none"></button>
<button class="read_book_button not_read_book" style="display: none"></button>


<script>
    //自动滚动事件
    var read_auto_button = document.querySelector('.read_auto_button');
    read_auto_button.onclick = function () {
        var start_or_stop = this.classList[1];
        if (start_or_stop == 'start_auto') {
            this.className = 'read_auto_button stop_auto';
            var gotoend = function () {
                var scroll_y = window.scrollY;
                scrollTo(scroll_y, scroll_y + 2);
            }
            Window.start = setInterval(gotoend, 100)
        } else {
            this.className = 'read_auto_button start_auto';
            clearInterval(Window.start)
        }

    };


    //判断是否出现正文出现正文的时候出现read按钮
    var topics = document.querySelector('#topics');
    var read_book_button = document.querySelector('.read_book_button');
    if (topics) {
        read_book_button.style.display = 'block'

    }

    //向上按钮点击事件
    var read_gotop_button = document.querySelector('.read_gotop_button');
    read_gotop_button.onclick = function () {
        window.scrollTo(0, 0);
    };

    //向下按钮点击事件
    var read_goend_button = document.querySelector('.read_goend_button');
    read_goend_button.onclick = function () {
        window.scrollTo(0, 9999);
    };

    read_book_button.onclick = function () {
        //点击事情跟换类名
        var class_name = this.classList[1];
        class_name == 'read_book' ? this.className = 'read_book_button not_read_book' : this.className = 'read_book_button read_book'

        //更换样式
        //头
        var head = document.querySelector('#header');
        //右侧
        var sideBar = document.querySelector('#sideBar');
        //评价栏
        var comment_form = document.querySelector('#comment_form');

        //正文无关的内容
        var blog_post_info_block = document.querySelector('#blog_post_
首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇CSS3-transition 下一篇【原】无脑操作:Webstorm集成Git..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目