zoukankan      html  css  js  c++  java
  • Toast

    <!doctype html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <title>加载中...</title>
    </head>
    
    <body>
        <button onclick="t()">弹出toast</button>
        <script src="http://lib.baomitu.com/jquery/3.2.1/jquery.min.js"></script>
        <script>
        var popToast = function() {}
        popToast.prototype = {
            timer: function(delay) {
                var t = null;
                clearTimeout(t);
                t = setTimeout(function() {
                    $(".toast-msg").fadeOut(200, function() {
                        $(".toast-msg").remove();
                    });
                }, delay);
            },
            toastMsg: function(content, position, delay) {
                var html = "";
                html = '<div class="toast-msg" style="position:fixed;margin:auto;padding:0.5rem 1.0rem;left:50%;bottom:1rem;transform: translate(-50%, -50%);-webkit-transform:translate(-50%, -50%);border-radius:0.33rem;font-size:1.08rem;color:#fff;background:rgba(0,0,0,.6);z-index:999;"><p>' + content + '</p></div>';
                if (position == 'center') {
                    html = '<div class="toast-msg" style="position:fixed;margin:auto;padding:0.5rem 1.0rem;top:50%;left:50%;transform: translate(-50%, -50%);-webkit-transform:translate(-50%, -50%);border-radius:0.33rem;font-size:1.08rem;color:#fff;background:rgba(0,0,0,.6);z-index:999;"><p>' + content + '</p></div>';
                }
                $("body").append(html);
                popToast.timer(delay);
            },
            remove: function(ele) {
                $(ele).remove();
            }
        }
        var popToast = new popToast();
    
        function t() {
            popToast.toastMsg('message123456','center',2000);
        }
        </script>
    </body>
    
    </html>
  • 相关阅读:
    npm 学习笔记
    Splash 学习笔记
    lodash 学习笔记
    运用 CSS in JS 实现模块化
    运用 CSS methodologies 去实现模块化
    less 学习笔记
    初探爬虫 ——《python 3 网络爬虫开发实践》读书笔记
    mitmproxy 使用笔记
    Appium 使用笔记
    Selenium 与自动化测试 —— 《Selenium 2 自动化测试实战》读书笔记
  • 原文地址:https://www.cnblogs.com/Doduo/p/8023330.html
Copyright © 2011-2022 走看看