js代码 :
function alert(e){
$("body").append("<div id='msg'><span>"+e+"</span></div>");
clearmsg();
}
function clearmsg(){
var t = setTimeout(function(){
$("#msg").remove();
},3500)
};
css样式:
#msg{
height: 2rem;
text-align: center;
position: fixed;
top: 50%;
margin-top: -1rem;
line-height: 2rem;
width: 100%;
}
#msg span{
color: #fff;
background: rgba(0,0,0,0.6);
height: 2rem;
display: inline-block;
padding: 0 3rem;
border-radius: 5px;
}
调用 :
alert("写你要展示提示的文字");
效果:可在css中设置弹窗的样式