图预加载,能把样式表的图片加载进来吗
css如下
.forshadow { float:left;
clear:left;
background: url(img/shadowAlpha.png) no-repeat bottom right !important;
background: url(img/shadow.gif) no-repeat bottom right;
margin: 10px 0 10px 10px !important;
margin: 10px 0 10px 5px;
width: 250px;
padding: 0px;}<div class="forshadow"></div>前提是这个div是不可以带id的,有很多组这样的div
css如下
.forshadow { float:left;
clear:left;
background: url(img/shadowAlpha.png) no-repeat bottom right !important;
background: url(img/shadow.gif) no-repeat bottom right;
margin: 10px 0 10px 10px !important;
margin: 10px 0 10px 5px;
width: 250px;
padding: 0px;}<div class="forshadow"></div>前提是这个div是不可以带id的,有很多组这样的div
用css和js有什么区别吗?
这样做是否多此一举?
用js能提高访问速度吗?
var img1 = new Image();
var img2 = new Image();
img1.src = "img/shadowAlpha.png";
img2.src = "img/shadow.gif";
</script>
<style>
.forshadow {
float:left;
clear:left;
background: url(img/shadowAlpha.png) no-repeat bottom right !important;
background: url(img/shadow.gif) no-repeat bottom right;
margin: 10px 0 10px 10px !important;
margin: 10px 0 10px 5px;
width: 250px;
padding: 0px;
}
</style>