首页 > 解决方案 > 背景图像在移动设备中不合适 - CSS

问题描述

我正在设计一个网页,它有一个固定的背景图像,我在移动视图中遇到了问题。就像,在桌面视图中,它完全没问题。然而,在移动视图中,图像太模糊并且不好看。我找不到我犯错的地方。我在这里附上了视图的图像和我的背景图像代码。

桌面: 桌面视图

移动的: Mobile_view

我的 CSS:

body 
  {
  font: 400 15px Lato, sans-serif;
  line-height: 1.8;
  color: #ffffff ;
  background-image: url(images/cover3.jpg);
  background-repeat: no-repeat;
  background-attachment: fixed;
  }

标签: htmlcss

解决方案


用这个

html { 
 background: url(images/bg.jpg) no-repeat center center fixed; 
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
  background-size: cover;
 }
 body{
background: none;
}

这个填充适合屏幕大小的背景


推荐阅读