android - 背景图像并不总是居中

标签 android html css twitter-bootstrap

我正在为我的期末元素制作一个网站,现在正在进行最后的润色。 我使用 bootstrap 编写它并使用了网格:.col-sm 现在我要确保它在所有屏幕分辨率下看起来都一样。

我通过我的 LG4 进入该网站,这是 View : enter image description here

但是当在我的电脑上使用 chrome 移动分辨率查看网站时,它看起来更像我想要的方式: enter image description here

这是CSS:

#index-wrap{
    background: url('pic/start.jpg') ;

    margin-bottom: 0;
    min-height: 50%;
    background-repeat: no-repeat;
    background-position: center center;
    -webkit-background-size: cover;
    background-size: cover;

    /*now:*/
     background-attachment: fixed;
}

.jumbotron {
    background-color: transparent; 
    color: #0E76BD; 
    text-align: center;
    height: 100vh;

}

这些是潜水层次结构:

<div id="index-wrap">
    <div class="jumbotron">

-----Site Content ------

    </div>
</div>

我该如何解决这个问题?

最佳答案

使用 background-size:cover 作为后备

background-size: 100vw auto;

它将背景宽度缩放到视口(viewport)的宽度,因此图像不会在任何支持视口(viewport)单位的设备(93% 的设备)上水平裁剪。

关于android - 背景图像并不总是居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44636638/

相关文章:

javascript - CSS Transition 在样式更改的相反方向上不起作用?

html - 将文本与表格和/或 div 重叠

Android 强制 HDMI 音频

Android 应用首选项正在自动清除

android - Shell脚本等待命令永远不会结束

android - 应用程序错误 - 与服务器的连接不成功。 (文件 :///android_asset/www/index. html)

javascript - 带有注释的 JavaScript 代码的 HTML

python - Python中GET和POST方法的问题

html - CSS 行高属性大于字体大小属性

css - 在 Bootstrap 布局中包装 ASP 表单