html - 在手机上覆盖背景大小

标签 html css background responsive

我的网站有问题。图片在桌面上看起来很棒,但在我的手机上看起来很糟糕,因为它放大了。

我该如何解决这个问题? 它不适用于

background-size:cover;

带背景的div有两个类

.content{
    color: white; 
    font-family: "Another Typewriter"; 
    width:100%; height:1000px;  
    font-size: 300%; 
    padding-left: 15%; 
    padding-right: 15%; 
    padding-top: 10%; 
    text-align: center; 
    background-size: cover;
}

.parallax{
    height: 100%; 
    background-attachment: fixed; 
    background-position: center; 
    background-repeat: no-repeat; 
    background-size: cover;
}
#xyz{background-image: url(URLtoimage);}

分区容器:

    <div id="xyz" class="parallax content">
    <legend class="text-center content-headline">XYZ</legend>
Some text
    </div>

最佳答案

我如何假设您正在使用 background-attachment: fixed; ,它不能在许多移动浏览器上工作,您必须使用媒体查询在小屏幕滚动时更改它。

.parallax{
   height: 100%; 
   background-attachment: fixed; 
   background-position: center; 
   background-repeat: no-repeat; 
   background-size: cover;
}

@media screen and (max-width: 600px) {
   .parallax {
        background-attachment: scroll; 
    }
}

关于html - 在手机上覆盖背景大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43574854/

相关文章:

javascript - 我无法使粘性标题工作

html - 如何在 <button> 标签上有一个 css 轮廓,只能通过选项卡,而不是点击?

css - 试图弄清楚为什么一个图像在容器外缩放

css - css div 标签中的背景图片

c++ - 使用 system() 执行后台进程

javascript - 无法更改 div 尺寸

html - 使用标签构建进度条

html - 将 Bootstrap 元素添加到 asp 文本框

java - Jsoup 从 div 的子级中抓取文本

ios - 在 UIViewController 中以编程方式径向渐变背景