CSS精灵写法
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
.div1{ width:420px;}
.div1 li { list-style: none; float:left; border:1px solid #EAF3FA; background:#FBFCFF; margin:10px; width:120px; height:40px; line-height:40px; padding-left:10px;}
.div span{padding-left:25px;/*空出16px来显示图标*/
height: 35px; /*设定好高度,让超出部分不可见*/
background:url(888888.png) no-repeat;/*所有的li共享一张图片*/}
.a{ background-position:-19px -22px; width:25px; height:20px;}
.b{ background-position:-146px -22px;width:25px; height:20px;}
.c{ background-position:-19px -68px;width:25px; height:25px;}
.d{ background-position:-146px -70px;width:25px; height:25px;}
.e{ background-position:-21px -120px;width:25px; height:25px;}
.f{ background-position:-145px -120px;width:25px; height:25px;}
.g{ background-position:-21px -120px;width:25px; height:25px;}
.h{ background-position:-21px -120px;width:25px; height:25px;}
.i{ background-position:-21px -120px;width:25px; height:25px;}
</style>
</head>
<body>
<div class="div1">
<ul>
<li><span class="a"></span><a href="#">aaaaa</a></li>
<li><span class="b"></span><a href="#">bbbbb</a></li>
<li ><span class="c"></span><a href="#">ccccc</a></li>
<li ><span class="d"></span><a href="#">ddddd</a></li>
<li ><span class="e"></span><a href="#">eeeee</a></li>
<li ><span class="f"></span><a href="#">eeeee</a></li>
<li ><span class="g"></span><a href="#">eeeee</a></li>
<li ><span class="h"></span><a href="#">eeeee</a></li>
</ul>
</div>
</body>
</html>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。