怎么给公司做个网站,网站建设需要注意的,商丘三合一网站建设,网站的字体通过css控制#xff0c;可以实现加载网络图片时#xff0c;未加载完成的时候显示本地一张占位图#xff0c;加载完成后显示网络图片#xff1b; 原理#xff1a;通过在img标签的after伪元素上添加一张占位图#xff0c;并且img都设置为position:relative;after设置positi…通过css控制可以实现加载网络图片时未加载完成的时候显示本地一张占位图加载完成后显示网络图片 原理通过在img标签的after伪元素上添加一张占位图并且img都设置为position:relative;after设置position:absolute;img标签的src为网络图片这样加载的时候由于网络图片没加载完成就会显示本地图片下面案例中的js是为了效果明显而故意延时设置img的src属性。 !DOCTYPE html
html langenheadmeta charsetUTF-8meta nameviewport contentwidthdevice-width, initial-scale1.0meta http-equivX-UA-Compatible contentieedgetitleDocument/titlestyleimg {position: relative;}img::after {content: ;height: 100%;width: 100%;position: absolute;left: 0;top: 0;background: url(iphonex.png ) no-repeat center;}/style
/headbodyimg src
/body
scriptsetTimeout(function() {document.querySelectorAll(img)[0].src //upload-images.jianshu.io/upload_images/7450593-65067eb4cf76d882.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240;}, 3000);
/script/html 转载于:https://www.cnblogs.com/010101-/p/10649026.html