最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

css - How can I make my overlay in Wordpress apply to the whole page viewport? - Stack Overflow

programmeradmin1浏览0评论

I have a simple overlay in a custom plugin I made that I'd like to display for my WordPress blog, but the overlay won't appear outside of the shortcode block. Here's my code,

plugin.php

    <?php
    function styleSetup() {
    wp_register_style('plugin-style', plugins_url('styles.css', __FILE__));
    wp_enqueue_style('plugin-style');
    }
add_action('wp_enqueue_scripts', 'styleSetup'); 
    function display_content() {
        ob_start(); ?>
    <div id="userConfirmationOverlay" class="overlay">
        <div id="userConfirmationBox" class="overlayBox">
            <h1>Is this you?</h1>
            <div id="avatar-image-container"></div>
        </div>
    </div>
        <form id="login-form" action="#" method="post">
            <input type="text" id="username" name="username" placeholder="Enter your username">
            <button type="submit">Get Avatar</button>
        </form>
    <script>
        document.getElementById('login-form').addEventListener('submit', function(event) {
        event.preventDefault();
        username = document.getElementById('username').value;
        console.log(username);
        openConfirmationOverlay;
    });
    function openConfirmationOverlay() {
    document.getElementById('userConfirmationOverlay').style.display = 'block';
    }
    </script>
    <?php>
    return ob_get_clean();
    }

styles.css:

.overlay {
    z-index: 3;
    height: 100%;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    overflow-x: hidden;
    display: none;
    position: fixed;
}

.overlayBox {
    position: relative;
    text-align: center;
    height: 50px;
    width: 50px;
}
add_shortcode('avatar_form', 'display_content');

How can I get the overlay to display on the whole page?

发布评论

评论列表(0)

  1. 暂无评论