首页 > 解决方案 > 图像相乘

问题描述

我试图让我的网站响应,但是当我拖动寡妇查看结果时,背景只是成倍增加。我有 2 张图片作为背景(1 张在开头,1 张在底部)

我试过了

@media screen and (max-width : 1600px) { 
  .bg1{
   background-size: 100%;
   background-repeat: no-repeat;
  }
}

如果我这样做,我会在图像之间得到一些空间。

HTML:

    <div class="bg1">
           *some content here*
      </div>

CSS:

    @media screen and (max-width : 1600px) { 
      .titlu h1{ font-size: 20rem; }
      .navbar li a{
       font-size: 20px;
      }
      .bg1{
        background-size: 100%;
        background-repeat: no-repeat;
      }
    }

标签: jqueryhtmlcss

解决方案


您可以使用background-position来放置图像并background-repeat避免重复

@media screen and (max-width : 1600px) {
  .bg1 {
    background-size: 100%;
    background-position: center;
    background-repeat: no-repeat;
  }
}

推荐阅读