首页 > 解决方案 > 如何将“背景图片放在另一个 div”上?

问题描述

这个问题可能并不酷,但想知道解决此任务的正确方法。当然使用 HTML、CSS、Bootstrap。 像这样的东西:

标签: htmlcssbootstrap-4

解决方案


快速示例,使用负边距顶部将部分放在其他部分上,如果您愿意,可以用背景图像替换样式。

   <section style="background:red;width:100%;height:300px">
   </section>
   <section style="width:100%;margin-top:-150px">
        <div class="container">
              <div style="width:100%;height:300px; background: white;"></div>
         </div>
   </section>

推荐阅读