如图所示的提示框
css
.toast{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%);
padding: 10px;
background-color: rgb(0,0,0,.6);
color: white;
border-radius: 5px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
height: 40px;
line-height: 20px;
box-sizing: border-box;
max-width: 80%;
animation: toastshow 0.5s;
}
@keyframes toastshow {
0%{ opacity: 0}
100%{opacity: 1}
}
js
var toasttimes = 0;
function toast(text) {
let div = document.createElement("div");
div.innerHTML = text;
div.className = "toast";
let i = 2;
//判断是否时第一次使用
if (toasttimes =