Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 是否可以从css(没有jQuery)延迟加载背景图像?_Html_Css_Lazy Loading - Fatal编程技术网

Html 是否可以从css(没有jQuery)延迟加载背景图像?

Html 是否可以从css(没有jQuery)延迟加载背景图像?,html,css,lazy-loading,Html,Css,Lazy Loading,横幅有一个背景类 background { background-image: url("../img/background_.jpg"); /* Create the parallax scrolling effect */ background-attachment: fixed; background-repeat: no-repeat; background-size: cover; background-position: center center; height: 6

横幅有一个背景类

background {
 background-image: url("../img/background_.jpg");
 /* Create the parallax scrolling effect */
 background-attachment: fixed;
 background-repeat: no-repeat;
 background-size: cover;
 background-position: center center;
 height: 60vh;
}
现在(2019年)是否可以加载图像?没有jQuery。

看看Echo.js()


它只有1kb大,因此不会对性能造成太大影响。上面的链接还显示了带有一些说明的源代码。

您可以尝试使用下面的代码

$("#layzy").lazyload();

演示:

如果没有我所知道的javascript,就不可能了-对于chrome,您可以使用loading=“lazy”来尝试一些肮脏的技巧属性,但我不建议这样做使用javascript的解决方案如何?使用javascript是可能的。我可以使用javascript提供解决方案吗?@ForamTrada请确保让我知道它是否有用?不幸的是,这是jQuery解决方案