<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>雪碧图</title>
<style type="text/css">
.box:link{
display: block;
width: 126px;
height: 88px;
background-image: url(img/amazon-sprite1_.png);
background-repeat: no-repeat;
}
.box:hover{
width: 126px;
height: 88px;
background-image: url(img/amazon-sprite2_.png);
}
</style>
</head>
<body>
<a href="#" class="box"></a>
</body>
</html>
使用图片整合技术:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>雪碧图</title>
<style type="text/css">
.box:link{
display: block;
width: 126px;
height: 88px;
background-image: url(img/amazon-sprite3_.png);
background-repeat: no-repeat;
}
.box:hover{
background-position: -146px 0px;
}
</style>
</head>
<body>
<a href="#" class="box"></a>
</body>
</html>
效果相同,但使用图片整合技术访问效率比较高,可以提高用户体验.
网友评论