HTML and CSS   XSLT   JavaScript   Images   Soft   Etc  
Vladimir Tokmakov

Saving on icons 2 June 2005


Task:

Reduce the number of requests to server when loading a page with many icons.

You can combine all icons into a single file, and then use it as a background image in required position.

How it looks in the browser

01 
02 
03 
04 
05 
06 
07 
08 
09 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
<style type="text/css">
    ul
    {
        padding: 0;
        margin: 0;
    }
    #services li
    {
        padding: 0;
        margin: 0 2em 0 0;
        float: left;
        list-style-type: none;
        position: relative;
    }
    #services a
    {
        padding: 0 0 0 18px;
        display: block;
        position: relative;
        text-decoration: underline;
        z-index: 2;
    }
    /* this element is needed to prevent IE background image reloading */
    #services i
    {
        position: absolute;
        z-index: 1;
        left: 0;
        top: -8px;
        width: 16px; height: 16px;
        margin-top: 0.6em;
        background: url('services.gif') no-repeat;
    }
    #narod i { background-position: -16px 0; }
    #maps i { background-position: -48px 0; }
    #money i { background-position: -96px 0; }
</style>
<ul id="services"> 
    <li id="maps"><i></i>http://maps.yandex.ru/">Maps</a></li>
    <li id="money"><i></i>http://money.yandex.ru/">Money</a></li>
    <li id="narod"><i></i>http://narod.yandex.ru/">Two barrels</a></li>
</ul>

Order a design...