在移动设备上滚动时图像无响应

时间:2018-02-14 19:47:42

标签: css responsive

每当我的图像达到6或更低的iphone宽度并向左滚动时,就会有一个边距。

  1. 图片未滚动 - https://i.stack.imgur.com/WMkb2.png
  2. 图片向左滚动 - https://i.stack.imgur.com/mxcQb.png
  3. 我的CSS:

    .background-image {
      z-index: -1;
      position: absolute;
      margin: 0px;
      height: 40%;
      width: 100%;
      background:         
        linear-gradient(rgba(74,74,74,0.21), rgba(74,74,74,0.21)), 
        url('./img/nyc_quarter.png') no-repeat center center; 
      -webkit-background-size: cover;
      -moz-background-size: cover;
      -o-background-size: cover;
      background-size: cover;
      background-position: center;
    }
    

1 个答案:

答案 0 :(得分:0)

你想要这样的想法吗?



nav
{
  background-color:black;
  height:30px;
  color:white;
}

#background
{
  background-image: url('https://weloveminitel.eu/snow2.jpg');
  background-size: cover;
  height:200px;
  color:white;
  display: flex;
justify-content: center;
flex-direction: column;
align-items: stretch;
text-align:center;
  
}

#bottom
{
  height:200px;
  border:1px solid black;
  
}

<body>
  <nav>
    navbar
  </nav>
  <div id="background">
    some text
  </div>
  <div id="bottom">
  the bottom div
  </div>
</body>
&#13;
&#13;
&#13;