简单好看的网站弹窗公告源码

简单好看的网站弹窗公告源码,自适应

演示

源码

[lv]

<div class="popup-overlay">
        <div class="popup">
            <h2>## 最新通知 ##</h2>
            <p>各位爱学习的同学,请进入最新地址学习:</p>
            <p>点击下方进入</p>
            <p><a href="https://www.dgzyku.com/" target="_blank" style="color: #ff0000;">【QQ资源吧 m.qqzy8.com】</a></p>
            <button onclick="closePopup()">关闭</button>
        </div>
    </div>

    <script>
        function closePopup() {
            document.querySelector('.popup-overlay').style.display = 'none';
        }

        window.onload = function () {
            document.querySelector('.popup-overlay').style.display = 'flex';
        };
    </script>
        <style>
        .popup-overlay {
            position: fixed;
            top: 0;
            left: 0;
            height: 100%;
            width: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 100;
        }

        .popup {
            position: relative;
            padding: 2rem;
            width: 500px;
            background-color: #ffffff;
            border-radius: 10px;
            box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.3);
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
        }

        .popup h2 {
            margin-bottom: 5px;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 8px;
            margin-top: 0;
            font-size: 2rem;
            line-height: 2.5rem;
            color: #007bf5;
        }

        .popup p {
            margin-top: 10px;
            font-size: 1.2rem;
            line-height: 1.5rem;
            color: #666666;
            margin-bottom: 1rem;
        }

        .popup button {
            padding: 0.5rem 1rem;
            background-color: #007bf5;
            color: #ffffff;
            border: none;
            border-radius: 4px;
            font-size: 1rem;
            cursor: pointer;
            margin-top: 1rem;
        }

        .popup button:hover {
            background-color: #303f9f;
        }

        @media (max-width: 600px) {
            .popup {
                width: 90%;
                padding: 1.5rem;
            }

            .popup h2 {
                font-size: 1.8rem;
                line-height: 2.3rem;
            }

            .popup p {
                font-size: 1.1rem;
                line-height: 1.4rem;
            }

            .popup button {
                font-size: 1rem;
                padding: 0.4rem 0.8rem;
            }
        }
    </style>

[/lv]