作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为我的期末元素制作一个网站,现在正在进行最后的润色。我使用 bootstrap 编写它并使用了网格:.col-sm现在我要确保它在所有屏幕分辨率下看起来都一样。
但是当在我的电脑上使用 chrome 移动分辨率查看网站时,它看起来更像我想要的方式:
这是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/
我是一名优秀的程序员,十分优秀!