zoukankan      html  css  js  c++  java
  • 关于 element 的 backToTop

    下面是一段完整的小demo。

    效果图示例:


    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>test</title>
        <script src="https://cdn.jsdelivr.net/npm/vue"></script>
        <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
        <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    </head>
    
    <style>
        * {
            box-sizing: border-box;
        }
    
        html,
        body {
            margin: 0;
            padding: 0;
        }
    
        .wraper {
            height: 100vh;
            border: 4px solid red;
            height: 500px;
            overflow: hidden;
            overflow-x: hidden;
            overflow-y: scroll;
        }
    
        .back-ball {
            background-color: tomato;
            color: #fff;
            border-radius: 22px;
            padding: 10px;
        }
    </style>
    
    <body>
    
        <div class="wraper">
            <template>
                Scroll down to see the bottom-right button.
                <el-backtop target=".wraper">
                    <div class="back-ball">
                        回到顶部
                    </div>
                </el-backtop>
            </template>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
            <h1>滚动内容部分</h1>
        </div>
    </body>
    <script>
        var vm = new Vue({
            el: '.wraper',
            data: {}
        })
    </script>
    
    </html>
    

    ** 注意: ** target挂载点需要是一个滚动区域(设置高度。overflow-y:scroll)

  • 相关阅读:
    小程序之滚动选择器(时间、普通、日期)
    bzoj 4825: [Hnoi2017]单旋 LCT
    bzoj 4821: [Sdoi2017]相关分析 线段树
    bzoj 4766: 文艺计算姬 矩阵树定理
    bzoj 4031: 小Z的房间 矩阵树定理
    bzoj 4822~4824 CQOI2017题解
    bzoj 4817: [Sdoi2017]树点涂色 LCT+树链剖分+线段树
    bzoj 4816: [Sdoi2017]数字表格
    bzoj 4537: [Hnoi2016]最小公倍数 分块+并查集
    bzoj 4653: [Noi2016]区间
  • 原文地址:https://www.cnblogs.com/niluiquhz/p/11298281.html
Copyright © 2011-2022 走看看