【问题标题】:How to get background to show full image如何获取背景以显示完整图像
【发布时间】:2019-12-06 03:33:48
【问题描述】:

无论浏览器的大小如何,我都试图让背景图像显示完整的图片。当我将浏览器设为全屏时,它会切断背景图像。

我已经调整了高度和背景大小。

html, body{
  height: 100%;
}
body{
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  background: url(https://66.media.tumblr.com/838ffe3b51b82759591aafe1ad820f47/tumblr_pexmxzbbjQ1ukgu7do1_1280.jpg);
  background-repeat: no-repeat;
  background-size: cover;
  height: ;
}

无论浏览器大小如何,预期结果背景始终显示完整图片。全屏时,实际结果背景会切断图片。我需要看到完整的灯泡。

【问题讨论】:

    标签: html css image background


    【解决方案1】:

    或者,您可以将宽度和高度设置为 100%:

    html, body{
      height: 100%;
    };
    
    body{
      margin: 0;
      padding: 0;
      font-family: sans-serif;
      background: url(https://66.media.tumblr.com/838ffe3b51b82759591aafe1ad820f47/tumblr_pexmxzbbjQ1ukgu7do1_1280.jpg);
      background-repeat: no-repeat;
      background-size: cover;
      width: 100%;
      height: 100%;
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多