zoukankan      html  css  js  c++  java
  • 自制弹框

    body中随意定义个<div class="alert"></div> 

    alert定义样式

    .alert {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    min-width: 300px;
    max-width: 600px;
    transform: translate(-50%,-50%);
    z-index: 99999;
    text-align: center;
    padding: 15px;
    border-radius: 3px;
    }

    .alert-success {
    color: #3c763d;
    background-color: #dff0d8;
    border-color: #d6e9c6;
    }

    .alert-info {
    color: #31708f;
    background-color: #d9edf7;
    border-color: #bce8f1;
    }

    .alert-warning {
    color: #8a6d3b;
    background-color: #fcf8e3;
    border-color: #faebcc;
    }

    .alert-danger {
    color: #a94442;
    background-color: #f2dede;
    border-color: #ebccd1;
    }

    js

    /**
    * 弹出式提示框,默认1.2秒自动消失
    * @param message 提示信息
    * @param style 提示样式,有alert-success、alert-danger、alert-warning、alert-info
    * @param time 消失时间
    */
    var prompt = function (message, style, time)
    {
    style = (style === undefined) ? 'alert-success' : style;
    time = (time === undefined) ? 1200 : time;
    $('<div>')
    .appendTo('body')
    .addClass('alert ' + style)
    .html(message)
    .show()
    .delay(time)
    .fadeOut();
    };

    // 成功提示
    var success_prompt = function(message, time)
    {
    prompt(message, 'alert-success', time);
    };

    // 失败提示
    var fail_prompt = function(message, time)
    {
    prompt(message, 'alert-danger', time);
    };
    // 提醒
    var warning_prompt = function(message, time)
    {
    prompt(message, 'alert-warning', time);
    };

    // 信息提示
    var info_prompt = function(message, time)
    {
    prompt(message, 'alert-info', time);
    };
    pasting
  • 相关阅读:
    用shell脚本监控进程是否存在 不存在则启动的实例
    vue+element-ui+ajax实现一个表格的实例
    c的指针和php中的引用的区别
    mysql or条件查询优化
    Linq查询操作之投影操作
    Linq查询操作之Where筛选
    Linq专题之查询操作
    linq之join子句
    linq之let子句
    linq之into子句
  • 原文地址:https://www.cnblogs.com/tflike/p/10929690.html
Copyright © 2011-2022 走看看