1、 什么是精灵图?
就是将几张较小的图片放在一张大图上,通过background-position
调整位置进行显示
2.、 使用精灵图的好处 :
3、 精灵图的使用
<div class="footer">
<div class="contain">
<div class="con-btn">
<a href="javascript:;" class="player-btn btn-prev" title="上一首">
a>
<a href="javascript:;" class="player-btn btn-play" title="暂停/继续">
a>
<a href="javascript:;" class="player-btn btn-next" title="下一首">
a>
<a href="javascript:;" class="player-btn btn-order" title="循环控制">
a>
div>
div>
div>
.footer {
z-index: 100;
height: 100px;
bottom: 0;
width: 100%;
position: absolute;
}
.contain {
position: relative;
width: 100%;
height: 100%;
background-color: #ccc;
max-width: 1200px;
margin: 0 auto;
}
/* 带图片的按钮 */
.player-btn {
background-image: url("../images/player.png");
opacity: 0.8;
filter: alpha(opacity=80);
}
.player-btn:hover {
opacity: 1;
filter: alpha(opacity=100);
}
/* 控制按钮(上一首、播放、下一首)区域 */
.con-btn {
float: left;
width: 130px;
height: 100%;
position: relative;
margin: 0 10px;
}
.con-btn a {
display: inline-block;
position: absolute;
top: 50%;
}
.btn-prev {
background-position: 0 -30px;
width: 19px;
height: 20px;
margin-top: -10px;
}
.btn-play {
width: 19px;
height: 29px;
margin-top: -14.5px;
left: 36%;
margin-left: -10.5px;
}
.btn-next {
background-position: 0 -52px;
right: 30%;
width: 19px;
height: 20px;
margin-top: -10px;
}
.btn-order {
background-position: 0 -173px;
background-size: 450%;
right: 0;
width: 25px;
height: 25px;
margin-top: -10px;
}