CSS image mosaic technology
1. split image
- MIX is a collection of images of a single image.
- There are lots of pictures of the pages may take a lot of time to load and generates multiple server requests.
- Using the image split reduces the number of requests to the server, and save bandwidth.
Examples of split image
- With css styles, we can show we need to part of the image
Detailed code is as follows:
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>图片整合</title>
<style>
.box{
width:200px;
margin:0 auto;
overflow:hidden;
}
.iton{
width:43px;
margin-left:10px;
height:44px;
float:left;
background:url(images/img_navsprites_hover.gif) no-repeat;
}
.span01{
background-position:0 0;
}
.span02{
background-position:-47px 0;
}
.span03{
background-position:-91px 0;
}
.span01:hover{
background-position:0 -45px ;
}
.span02:hover{
background-position:-47px -45px ;
}
.span03:hover{
background-position:-91px -45px ;
}
</style>
</head>
<body
<div class="box">
<span class="iton span01"></span>
<span class="iton span02"></span>
<span class="iton span03"></span>
</div>
<body>
</html>
FIG results are as follows:
- The effect of adding a suspension style
- Hovering over elements set position background-position to change the picture location