【问题标题】:Background image - Let run image into other div?背景图像 - 让图像进入其他 div?
【发布时间】:2018-02-20 08:14:26
【问题描述】:

我想将this image 设置为this page 上的背景图像。我想让背景图像在navbar navbar-default 类中开始。现在我的问题来了。我希望图像继续到下一个名为

的 div
class="elementor-element elementor-element-gjr87i6 elementor-section-boxed elementor-section-height-default elementor-section-height-default elementor-section elementor-top-section"

我该如何实现呢? - 我已经尝试过溢出,但我没有得到它的工作。

【问题讨论】:

    标签: javascript jquery html css image


    【解决方案1】:

    你必须将背景图片设置为一个div,并且你必须在这个div中放置你想要共享相同背景的其他div。

    【讨论】:

    • 你能举个例子吗?
    【解决方案2】:

    您可以将 div 包装在一个公共父 div 中并将背景图像应用到该父 div。使用 jQuery wrapAll() 函数动态包装它们(假设它们是相邻的 div's )。

    <div class='wrap'>
      <div class='navbar navbar-default'></div>
      <div class='elementor-element elementor-element-gjr87i6 elementor-section-boxed elementor-section-height-default elementor-section-height-default elementor-section elementor-top-section'></div>
    </div>
    
    .wrap {
      background: url('...') no-repeat;
      background-size: cover;
    }
    
    $('.navbar-default, .elementor-top-section').wrapAll('<div class="wrap"></div>');
    

    【讨论】:

    • 很遗憾,我不能这样做,因为它是一个 wordpress 网页
    • @ChantelleWedel 您可以使用 jQuery 动态包装它们。我已经更新了答案。
    猜你喜欢
    • 2015-07-04
    • 2015-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-16
    • 2015-11-20
    相关资源
    最近更新 更多