Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
682 views
in Technique[技术] by (71.8m points)

CSS设置的背景图片如何判断是否加载完成

用css添加一个背景图片,现在我做了一个加载动画,想在图片加载完成后隐藏,但不知道如何判断css添加的图片什么时候加载完成。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

var bg = new Image();
另 bg.src 为背景图的src,bg对象complete的时候就表示加载完成了。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...