首页 > 如何控制div背景的高度并使div背景图的高度跟随div的缩小而缩小

如何控制div背景的高度并使div背景图的高度跟随div的缩小而缩小

现有div的高度为95%,但其背景图片的高度依然是100%,如何调? 而且希望能够设置为响应式的,能跟随屏幕的缩放。

#apDiv1 {
position: absolute;
left: 1400px;
top: 0px;
width: auto;
height: 95%;
background-color: #f0f0f0;
overflow-x: hidden;
overflow-y: hidden;
z-index: 22;
background-position: 0 0px;
background-image: url('../images/bgALL02_01.png');
background-repeat: repeat-x;
}

当浏览器100%高度div95%高度时,这里的草只显示了一半

当浏览器缩小时草就看不到了


如果可以使用 background-size 属性的话,就

background-size: contain

【热门文章】
【热门文章】