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)

  • 相关阅读:
    第三周学习笔记
    Python简易购物车程序
    记录回忆,谢谢你,别忘了我。
    学习第二周
    入园3个月首次写个帖
    Linux系统mysql多实例主从
    linux系统开机流程和启动nginx
    linux系统rsync命令
    linux监控进程状态命令自定义rpm包及kill命令
    linux搭建yum仓库
  • 原文地址:https://www.cnblogs.com/niluiquhz/p/11298281.html
Copyright © 2011-2022 走看看