css如何使background-img填满整个页面 页面使用ajaxheight会发生变化bodybefore 伪元素你好强大! content ; position absolute; top 0; left 0; width 100; height 100; background-image urlbackendwebresourcesi
可以尝试使用以下方法来实现背景图片全覆盖:
- 设置html和body元素的高度为100%:
html, body {
height: 100%;
}
- 将伪元素的高度设置为100vh:
body::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100vh;
background-image: url('/backend/web/../../resources/image//雪舞☆九天.gif');
filter: invert(100%);
z-index: -1;
}
vh(viewport height)是一个相对于视口高度的单位,100vh表示整个视口高度。这样设置可以确保伪元素的高度始终等于整个页面高度,从而实现背景图片全覆盖。
原文地址: https://www.cveoy.top/t/topic/cRle 著作权归作者所有。请勿转载和采集!