我们拥有的背景图片是1920x1080p,它可以在桌面浏览器上正确显示,但不能在移动设备上显示(不是在纵向或横向模式下)。无论如何要解决这个问题?我需要多张图片还是有办法自动调整大小?这是.css文件。
#tf-home{
background: url(../images/OdysseyTitleImage.jpg);
background-size: cover;
background-position: center;
background-attachment: fixed;
background-repeat: no-repeat;
color: #cfcfcf;
}
#tf-home .overlay{
background: -moz-linear-gradient(top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.73) 17%, rgba(0,0,0,0.66) 35%, rgba(0,0,0,0.55) 62%, rgba(0,0,0,0.4) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.8)), color-stop(17%,rgba(0,0,0,0.73)), color-stop(35%,rgba(0,0,0,0.66)), color-stop(62%,rgba(0,0,0,0.55)), color-stop(100%,rgba(0,0,0,0.4))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.73) 17%,rgba(0,0,0,0.66) 35%,rgba(0,0,0,0.55) 62%,rgba(0,0,0,0.4) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.73) 17%,rgba(0,0,0,0.66) 35%,rgba(0,0,0,0.55) 62%,rgba(0,0,0,0.4) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.73) 17%,rgba(0,0,0,0.66) 35%,rgba(0,0,0,0.55) 62%,rgba(0,0,0,0.4) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.73) 17%,rgba(0,0,0,0.66) 35%,rgba(0,0,0,0.55) 62%,rgba(0,0,0,0.4) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cc000000', endColorstr='#66000000',GradientType=0 ); /* IE6-9 */
height: 1080px;
background-attachment: fixed;
}
.home-lead{
color: #fff;
padding: 10px 15px;
background-color: rgba(51, 51, 51, 0.9);
font-size: 21px;
}
.content{
position: relative;
padding: 30% 0 0;
}
这是.html文件
<div id="tf-home" class="text-center">
<div class="overlay">
<div class="content">
<div><a href="https://www.youtube.com/watch?v=HRlP0t41wCw" class="btn tf-btn btn-default popup-video">Watch the trailer</a></div>
<a href="#tf-game" class="fa fa-angle-down page-scroll"></a>
</div>
</div>
</div>
答案 0 :(得分:0)
这可能是由height: 1080px;
中的#tf-home .overlay
引起的。它在桌面上看起来很不错,因为它具有很高的必要空间。但同样的高度也适用于移动设备,因此图形区域比平均移动视口大得多。
您是否尝试在移动设备的媒体查询中创建更合适(更小)的高度?例如。
@media (max-width: 600px) {
#tf-home{
background-attachment: scroll;
}
#tf-home .overlay {
height: 320px;
}
}