我想创建一个覆盖整个屏幕宽度的框,以便始终响应全屏幕宽度。
我当前的CSS代码总是将框限制为Boddy,但我想要全宽。
另外,我想在盒子里放一张背景图片。
有人能帮我吗?
我的CSS:
div.bg {
background-image: url("LINK TO PIC");
background-repeat: no-repeat;
background-size: cover;}发布于 2016-06-19 20:18:16
是不是有什么东西阻止你把div设置为position:fixed?
如果没有,那就很简单了:
div.bg
{
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: auto;
background-image: url("LINK TO PIC");
background-repeat: no-repeat;
background-size: cover;
}发布于 2016-06-19 21:13:00
使用Viewport units: vw, vh, vmin, vmax
div.bg {
background-image: url("LINK TO PIC");
background-repeat: no-repeat;
background-size: cover;
width: 100vw;
height: 100vh;
}发布于 2016-06-19 22:10:07
div.bg {
background-image: url("LINK TO PIC");
background-repeat: no-repeat;
background-size: cover;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: auto;
z-index: 9;}https://stackoverflow.com/questions/37907093
复制相似问题