toast弹出框效果

js代码

 1 //toast弹出框
 2 var layerTime;
 3 function layer(txt, time) {
 4     clearTimeout(layerTime);
 5     var times = time || 2000;
 6     $(".layer_wrap").remove();
 7     $("body").append(‘<div id="layer_wrap" class="layer_wrap"></div>‘);
 8     $(".layer_wrap").append(‘<p id="layer" class="layer sct">‘ + txt + "</p>");
 9     var o = $(".layer").height();
10     var p = $(".layer").width();
11     $(".layer_wrap").css({
12         "margin-top": -o / 2
13     });
14     layerTime = setTimeout(function() {
15         $(".sct").removeClass("layer").addClass("unlayer");
16         $(".sct").on("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend",function(){
17             $(".layer_wrap").remove();
18         });
19     },
20     times)
21 }

css 代码

 1 @keyframes ss {
 2     0% {
 3         opacity: 0;
 4         -webkit-transform: scale(.5);
 5         -ms-transform: scale(.5);
 6         transform: scale(.5)
 7     }
 8
 9     100% {
10         opacity: 1;
11         -webkit-transform: scale(1);
12         -ms-transform: scale(1);
13         transform: scale(1)
14     }
15 }
16
17 @keyframes sss {
18     0% {
19         opacity: 1;
20         -webkit-transform: scale(1);
21         -ms-transform: scale(1);
22         transform: scale(1)
23     }
24
25     100% {
26         opacity: 0;
27         -webkit-transform: scale(.5);
28         -ms-transform: scale(.5);
29         transform: scale(.5)
30     }
31 }
32
33 .layer_wrap {
34     position: fixed;
35     width: 9rem;
36     top: 50%;
37     left: 50%;
38     margin-left: -4.5rem;
39     margin-top: -1rem;
40     text-align: center;
41     z-index: 9999999;
42 }
43
44 .layer {
45     min-width: 3rem;
46     background-color: rgba(0,0,0,.6);
47     border-radius: 8px;
48     display: inline-block;
49     color: #fff;
50     font-size: .32rem;
51     text-align: center;
52     line-height: .4rem;
53     padding: .3rem .6rem;
54     word-break: break-all;
55     animation-name: ss;
56     animation-duration: .3s;
57     animation-timing-function: ease;
58     animation-fill-mode: both;
59     -ms-animation-name: ss;
60     -ms-animation-duration: .3s;
61     -ms-animation-timing-function: ease;
62     -ms-animation-fill-mode: both;
63     -webkit-animation-name: ss;
64     -webkit-animation-duration: .3s;
65     -webkit-animation-timing-function: ease;
66     -webkit-animation-fill-mode: both
67 }
68
69 .unlayer {
70     background-color: rgba(0,0,0,.6);
71     border-radius: 8px;
72     display: inline-block;
73     color: #fff;
74     font-size: .32rem;
75     text-align: center;
76     line-height: .4rem;
77     padding: .3rem .6rem;
78     word-break: break-all;
79     animation-name: sss;
80     animation-duration: .2s;
81     animation-timing-function: ease;
82     animation-fill-mode: both;
83     -ms-animation-name: sss;
84     -ms-animation-duration: .2s;
85     -ms-animation-timing-function: ease;
86     -ms-animation-fill-mode: both;
87     -webkit-animation-name: sss;
88     -webkit-animation-duration: .2s;
89     -webkit-animation-timing-function: ease;
90     -webkit-animation-fill-mode: both
91 }

原文地址:https://www.cnblogs.com/mk2016/p/10087073.html

时间: 2024-08-25 22:10:20

toast弹出框效果的相关文章

Axure 动态面板实现弹出框效果

今天在画原型图的时候遇到了个弹出框效果的实现,感觉挺有意思的,拿出来share下~ 如图:当我点击删除按钮后,如果用户选择删除,则要求要弹出一个对话框来让用户输入处理备注,如果不要删除,则点击取消: 首先描述下大致思路,我在页面上加上一个动态面板,然后为这个动态面板加上两个状态,一个是显示弹出框,另一个是隐藏弹窗口. 下面是弹出对话框的两个状态的设计: 隐藏状态的动态面板设置为空白,这样当切换到这个状态时就看不到任何东西. 然后为删除按钮添加用例: 注意,这里是当发生单击事件的时候弹出动态面板,

jquery 弹出框效果

html <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>弹出框效果</title> <script type="text/javascript" src="js/jquery-3.0.0.min.js" ></script> <script type="tex

bootstrip 实现弹出框效果

modal是Bootstrap提供的一个“窗口组件”,可以配合js实现弹出窗口的效果. modal的class是“modal”,其中必须包含三个div部分,属性分别问modal-header,modal-body,modal-footer. 同时modal可以用来放置注册表单,示例如下: [html] view plaincopyprint? <section> <div class="row"> <div class="span12"

代码录播:jQueryMobile 实现一个简单的弹出框效果

今天给大家带来的是 jQueryMobile 实现一个简单的弹出框效果,有兴趣的童鞋可以试试哦~ ^_^ 阅读原文:www.gbtags.com

安卓开发笔记——PopupWindow,做出如弹出框效果

先看一个效果图 点击按钮后出现一个这么的效果,这个弹出框实现的答题代码如下 先来一个弹出框的布局xml 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent"

自定义弹出框效果

对网站而言,弹出框是比较常见的.或是给出用户操作提示,或是通过弹出框打开一个小窗口以提示信息,或是给出错误警示等等. 但是由于浏览器自带的弹出窗口alert , confirm , prompt样式比较单调,且不同浏览器有不同的默认样式设置. 所以在日常工作中,给网站做一个自定义的弹出框十分必要.特别是富交互的网站 一.提示框 html部分: 1 <!--修改弹窗--> 2 <div class="pop-alert" id="pop" style

蒙版弹出框效果

自定义 package cn.lxsdb.yyd.app.dialog;      import cn.lxsdb.yyd.app.R;   import cn.lxsdb.yyd.app.constants.AppIntent;   import android.app.Dialog;   import android.content.Context;   import android.content.Intent;   import android.os.Bundle;   import a

控制非模态弹出框(showModelessDialog)唯一且随父页面关闭

网站开发中,常常会遇到需要弹出窗体的情况,一般弹出框有模态和非模态两种,如下: 模态:window.showModalDialog() 非模态:window.showModelessDialog() 另外还有window.open 方法,以及通过div来模拟弹出框效果的形式. window.open请自行百度,了解不深:div模拟的方式不适用与,弹出框中某些组件与父页面组件不相容的情况,如笔者所在项目,父页面中的jquery与整个网站js框架不相容(当然不是简单的可以通过替换$关键字来解决).所

bootstrap中popover.js(弹出框)使用总结+案例

bootstrap中popover.js(弹出框)使用总结+案例 *bootstrap官方说明:http://v3.bootcss.com/javascript/#popovers 一. popover常用配置参数: 1 //常用配置参数: 2 $(document).ready(function() { 3 $('#temp').popover( 4 { 5 trigger:'click', //触发方式 6 template: '', //你自定义的模板 7 title:"标题",