jQuery: How can i create a simple overlay?

后端 未结 7 1808
感动是毒
感动是毒 2020-11-30 19:04

How can I create a really basic overlay in jQuery without UI?

What is a lightweight plugin?

7条回答
  •  庸人自扰
    2020-11-30 19:20

    Here is a simple javascript only solution

    function displayOverlay(text) {
        $("
    " + text + "
    ").css({ "position": "fixed", "top": 0, "left": 0, "width": "100%", "height": "100%", "background-color": "rgba(0,0,0,.5)", "z-index": 10000, "vertical-align": "middle", "text-align": "center", "color": "#fff", "font-size": "30px", "font-weight": "bold", "cursor": "wait" }).appendTo("body"); } function removeOverlay() { $("#overlay").remove(); }

    Demo:

    http://jsfiddle.net/UziTech/9g0pko97/

    Gist:

    https://gist.github.com/UziTech/7edcaef02afa9734e8f2

提交回复
热议问题