【问题标题】:Interactions with Background being blocked by Div over the background与背景的交互被 Div 在后台阻止
【发布时间】:2016-01-12 05:57:31
【问题描述】:

我在后台使用Particles.js。我在包含文本和图像的画布上有 div 层。

这个 div 会阻止与背景的交互,从而扼杀体验。有没有办法确保 div 允许通过它与背景进行交互。在 Div 上方和下方,交互效果很好,因为内容是垂直居中的。

Demo Link

【问题讨论】:

    标签: javascript jquery css z-index particles.js


    【解决方案1】:

    我在您的代码中看到了这个 css。 (第 19 行)

    #hero-unit .particles-js-canvas-el {
        z-index: -1 !important;
    }
    

    改成

    #hero-unit .particles-js-canvas-el {
        z-index: 1 !important;
    }
    

    #hero-unit #hero-wrapper {
        z-index: 1!important;
    }
    

    修复通过文本或旁边的文本进行交互

    将 div 包装在单独的 .col-md-9 rows

    <div class="row">
        <!--  first row -->
        <div class="col-md-9">
            <img class="hero-logo hidden-xs" src="http://creo.mink7.com/wp-content/themes/creo/images/logo-home.png" alt="">
            <h1 class="head">Together we can Make a universe of smart innovations for a Better tomorrow</h1> 
        </div>
    
        <!--  second row -->
        <div class="col-md-9 newsletter">
            <div id="frontpage-mailchimp">
                <h4>Join the Community of Makers</h4>
    
                <!-- MailChimp for WordPress v3.0.10 - https://wordpress.org/plugins/mailchimp-for-wp/ -->
                <form id="mc4wp-form-1" class="mc4wp-form mc4wp-form-114" method="post" data-id="114" data-name="Join us in making things better">
                    <!--  mailchimp stuffs -->
                </form>
            </div>
        </div>
    </div>
    

    最后,这个 css

     #hero-wrapper .col-md-9{
            z-index: 1; // reduce the default z-index for div
        } 
    
    #hero-wrapper .col-md-9.newsletter{
        z-index: 9999; // increase the z-index for newletter div only
     } 
    

    【讨论】:

    • 当我这样做时,我无法在表单中输入电子邮件地址。
    • 更新了答案。通过添加这些代码,您现在也可以访问电子邮件表单了。
    • 谢谢。有没有办法可以通过文字或者旁边的互动?
    • @HarshaMV 找到了修复方法:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多