WEB前端开发HTML图片图片加载-从模糊到清晰楊遠徵2020-07-022024-05-12网页图片从模糊到清晰,可提升网页显示效果,增强用户体验感,具体代码如下。 复制下面代码后点我尝试运行123456789101112131415161718192021222324252627282930<!DOCTYPE html><html><head> <title>大图片加载从模糊到清晰</title></head><body style="text-align:center"> <h3>大图片加载从模糊到清晰</h3> <div class="mark" style='background-image:url(https://img.ssss.fun/2020/20200705135030.png);background-size:100%; filter: blur(4px);transition: all 2.5s;width: 100%;height: 450px;margin-top: 20px;'> </div> <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <script type="text/javascript"> // 为了看到效果加个延时 setTimeout(function(){ // 若图片URL失效请自行替换 var imgUrl = 'https://img.ssss.fun/2020/20200705135030.png'; var imgObject = new Image(); imgObject.src = imgUrl; imgObject.onload = function(){ $('.mark').css({ backgroundImage: 'url('+imgUrl+')', filter: 'blur(0)' }); } }, 1000) </script></body></html>