【发布时间】:2018-02-09 14:19:48
【问题描述】:
我在移动设备上使用视差背景图片时遇到了一些问题。当它显示在移动设备上时,图像会被放大,所以我看不到它是什么,无论我在横向还是纵向使用它都没有关系。同样的问题也出现在平板电脑上。
我用background-size: 100% auto; 试过了,现在你可以看到它了,但它实在是太丑了。
还尝试了background-size: contain;,但这也没有完成这项工作并且也弄乱了桌面视图。
视差功能也无法在移动设备上运行,但这对我来说并不重要。
同样的问题也出现在平板电脑上。
Here's what you see on mobile, when I use background-size: cover;
Here's what you see on mobile, when I use background-size: 100% auto;
.intro {
position: relative;
width: 100%;
height: 100%;
color: #fff;
background-color: #111;
min-height: 600px;
padding: 0;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-position: center center;
overflow: hidden;
background-attachment: fixed;
}
<section id="intro" style="background-image: url('img/background.jpg'); no-repeat;" class="intro">
感谢您的帮助
附:我是新来的,所以我希望我问的是正确的方法:)
【问题讨论】:
标签: html css twitter-bootstrap image background