use CSS sprites for list (
  • ) background image
  • 前端 未结 7 1239
    春和景丽
    春和景丽 2020-12-30 19:51

    Is it possible to use CSS sprites for the list background image? Normally, I render my sprites with CSS like this:

    .sprite { background: url(sprite.png) no-r         
    
    
            
    7条回答
    •  滥情空心
      2020-12-30 20:18

      you can use exactly the same method to do CSS sprites on a List. Here's a quick sample:

      ul { 
        list-style-type:none;
      }
      
      ul li {
        background:url(images/list-image.gif) no-repeat;
        height:24px;
      }
      
      ul li.comment {
        background-position: 0 -24px;
        /*Override properties here if you wish */
      }
      

      And the html

      • Test

      You'll have to remove the default padding/margin with the appropriate CSS styles. Personally i've not seen the list-style-image stuff being used before but know the above is a common solution.

    提交回复
    热议问题