0
votes

im trying to build a horizontal menu with images sprites and text

Here is an image of what i want but failing to accomplish with css.

Fig1

my css looks like this.


    #top_menu {
        color: #FFFFFF;
        height: 40px;
        background-color:#222;
        float: right;
    }
    #top_menu ul {
        font-size: 13px;
        margin-top: 13px;
    }
    #top_menu li {
        display: inline;
        list-style-type: none;
        padding-right: 10px;
    }

    .sprite {background:url(images/sprite.png);}
    .transparent {background:url(/images/transparent.png);}
        .contact {height:18px;}


            /*Top menu icons*/
             .sales{width:13px;background-position:-1px -72px;}
             .login{width:13px;background-position:-15px -72px;}
             .forum{width:13px;background-position:-29px -72px;}
                     .livechat{width:13px;background-position:-44px -72px;}

The html part

 <div id="top_menu" class="grid_6">
      <ul id="top_nav">
        <li class="sprite contact sales"><span>Sales:1-800-555-7777</span></li>
        <li class="sprite contact login"><span>Administrator</span></li>
        <li class="sprite contact forum"><span>Forum</span></li>
        <li class="sprite contact livechat"><span>Live Chat</span></li>
      </ul>
    </div>

As you can see, the images are on top of the text and also showing more than one icon. :( Fig2

Can anyone please help me out with this? I don't want to call each icon by separate. Thanks a lot!

1
Can you post the sprite?Joseph Silber

1 Answers

1
votes

You'll have to create your sprites a little differently.

Instead of putting the icons next to each other, put them on top of each other. That way, all you have to do is adjust the y positioning to get to the icon you want.

You might also be interested in using one of these tools:

http://csssprites.com/

http://spriteme.org/