一、完成列表的结构后开始为列表中li i添加雪碧图样式
提示: 1.首先为li添加不同的class,因为他们的background position值是不同的 2.根据li上添加的class,书写响应的样式 3.注意position的值为负数,因为雪碧图使用的坐标系是第四象限
说明: 第 55 行代码注释。
<html> <head> <meta http-equiv="Content-Type"content="text/html; charset=utf-8"/> <style> blockquote, body, button, dd, dl, dt, fieldset, form, h1, h2, h3, h4, h5, h6, hr, input, legend, li, ol, p, pre, td, textarea, th, ul{ margin: 0; padding: 0; } h3 { display: block; margin: 0; padding: 0; } .cat { position: relative; width: 150px; background: #f8f8f8; border: 1px solid #bbb; } ol, ul { list-style: none; } li { z-index: 2; position: relative; display: block; height: 31px; line-height: 31px; overflow: hidden; margin: 1px 10px 0; vertical-align: bottom; border-bottom: 1px solid #dedede } li h3 { font-size: 14px; font-weight: 400; } li i { display: inline; float: left; margin: 3px 10px 0 0; height: 24px; width: 30px } /* 在这里补充雪碧图的样式 */ </style> </head> <body> <div class="cat"> <ul > <li> <i></i> <h3>服装内衣</h3> </li> <li class="cat-2"> <i></i> <h3>鞋包配饰</h3> </li> <li> <i></i> <h3>运动户外</h3> </li> <li> <i></i> <h3>珠宝手表</h3> </li> <li> <i></i> <h3>手机数码</h3> </li> <li> <i></i> <h3>家电办公</h3> </li> <li> <i></i> <h3>护肤彩妆</h3> </li> <li > <i></i> <h3>母婴用品</h3> </li> </ul> </div> </body> </html>