How do I set the picture background in css:list-style-image?

Source: Internet
Author: User
, the bullet on the left is a picture, and now it's misplaced. How to set the margin of the picture?

Do not list-style-image this attribute
Use Background:url (1.png) no-repeat 74px;

Hehe really is using the wrong attribute Oh, with Li background or li a background to simulate list-type-image better, at least the location is not so difficult

Well. Not how to use list-type-image before, think it has the function of positioning. It still doesn't look right.

Is it possible to add the file name of the background image one by one:

For example, there are 10 Li, background images from icon1.gif to icon10.gif, these background images are to be displayed in front of Li. Can you just define a CSS implementation? Do you have to define 10 calls each?

/*-----------------------------------. top10-----------------------------------*/#top10 li {line-height:160%;        padding-left:24px;        border-bottom:1px #ccc dashed;        width:150px; Overflow:hidden;} #top10 a:hover {color: #C90;} #top10. Top1 {background:url (images/top_1.gif) no-repeat left center;} #top10. Top1 a {color: #06f;} #top10. TOP1 a:hover {color: #f60;} #top10. top2 {background:url (images/top_2.gif) no-repeat left center;} #top10. Top2 a {color: #06f;} #top10. top2 a:hover {color: #f60;} #top10. top3 {background:url (images/top_3.gif) no-repeat left center;} #top10. TOP3 a {color: #0066FF;} #top10. top3 a:hover {color: #f60;} #top10. TOP4 {background:url (images/top_4.gif) no-repeat left center;} #top10. top5 {background:url (images/top_5.gif) no-repeat left center;} #top10. TOP6 {background:url (images/top_6.gif) no-repeat left center;} #top10. TOP7 {background:url (images/top_7.gif) no-repeat left center;} #topTen. TOP8 {background:url (images/top_8.gif) no-repeat left center;} #top10. TOP9 {background:url (images/top_9.gif) no-repeat left center;} #top10. Top10 {background:url (images/top_10.gif) no-repeat left center;}

Not a definition, then the first 10 connected to a vertical string, make a picture----;
Next there are two methods:
1. Put the picture as the background of the UL, pitch + picture height =li line-height. Cons: You have to make sure Li doesn't fold.
2. Use JS to determine the number of Li that appears, respectively, to give corresponding background-position:*px; the value of "*".
--------------------
Benefits: Images only need to be requested once on the server, which is very important for large sites.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.