js默認提示框
js有三種默認提示框
提示框 alert('hello world!');

自定義提示框
下文通過js自動生成一個自定義提示框
function showDialog(content) { var layer = document.createElement("div"); layer.id = "layer"; var style = { background: "#ccc", position: "absolute", zIndex: 10, width: "auto", height: "40px", left: "50%", top: "0%", marginLeft: "-100px", marginTop: "10px", padding: "4px 10px" } for (var i in style) { layer.style[i] = style[i]; } if (document.getElementById("layer") == null) { document.body.appendChild(layer); layer.innerHTML = content; layer.style.textAlign = "center"; layer.style.lineHeight = "40px"; setTimeout("document.body.removeChild(layer)", 3000) } }
效果如下:

參考文章:
- Html隱藏方式 https://blog.csdn.net/weixin_43846130/article/details/95963426
- Flex布局 https://www.cnblogs.com/kybs0/articles/12205052.html
- 獲取元素 https://blog.csdn.net/simon_xing/article/details/81395854
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/58532.html
標籤:Html/Css
下一篇:BFC原理
