“背景尺寸:封面"不覆盖手机屏幕 [英] "background-size: cover" does not cover mobile screen

查看:28
本文介绍了“背景尺寸:封面"不覆盖手机屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 background-size:cover 在我的网站上有一个照片背景.它在大多数情况下都有效,但在我的 Galaxy S3 纵向模式下会留下一个奇怪的约 30 像素的空白区域.

I have a photo background on my site using background-size:cover. It works for the most part but leaves a weird ~30px white space on my Galaxy S3 in portrait mode.

我附上了截图.1px 青色线是为了说明整个屏幕.似乎背景在社交媒体 uls 之后立即停止.

I've attached a screenshot. The 1px teal line is to illustrate the entire screen. Seems like the background stops right after the social media uls.

我通过删除 ul 进行了测试,背景将其附加到标语文本的底部.

I tested this by removing the ul and the background attached it self to the bottom of the tagline text.

另外,这是我与移动端肖像视图相关的 CSS:

Also, here's my CSS pertaining mobile portait view:

@media only screen and (max-width: 480px) {

.logo {
    position: relative;
    background-size:70%;
    -webkit-background-size: 70%;
    -moz-background-size: 70%;
    -o-background-size: 70%;
    margin-top: 30px;
}   

h1 {
    margin-top: -25px;
    font-size: 21px;
    line-height: 21px;
    margin-bottom: 15px;
}

h2 {
    font-size: 35px;
    line-height: 35px;
}

.footer_mobile {
    display: block;
    margin-top: 20px;
    margin-bottom: 0px;
}

li {
    display: block;
    font-size: 1.3em;
}

这以前不会发生,但我想我在尝试解决另一个问题时不小心弄错了它.

This used to not happen, but I guess I accidentally bugged it while trying to solve another issue.

推荐答案

经过数小时尝试不同的事情,在 htmlmin-height: 100%;> 在 { background:... } 下为我工作.

After hours of trying different things, adding min-height: 100%; to the bottom of html under the { background:... } worked for me.

这篇关于“背景尺寸:封面"不覆盖手机屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆