-->

css sprite navigation

2019-07-27 06:53发布

问题:

Is it possible to use three images in CSS sprite navigation?

This may be like this

My image http://img710.imageshack.us/img710/1429/navigx.jpg

If its possible what will be the result?

回答1:

You can use any amount of images in a sprite, just move the positioning around in your CSS:

.sprite1
{
background-image:url(../../upload/btn_continue_sprite.png);
    background-repeat:no-repeat;
    background-position: -10px 5px;
}

.sprite1:hover
{
background-image:url(../../upload/btn_continue_sprite.png);
    background-repeat:no-repeat;
    background-position: -20px 10px;
}

.sprite2
{
background-image:url(../../upload/btn_continue_sprite.png);
    background-repeat:no-repeat;
    background-position: -30px 15px;
}

.sprite2:hover
{
background-image:url(../../upload/btn_continue_sprite.png);
    background-repeat:no-repeat;
    background-position: -40px 20px;
}

Just have to figure out the px distances to align the sprite to the element properly and you're away!

Hope that helps.



回答2:

Yes it is possible. See exaple here http://www.ehousestudio.com/blog/view/css_sprite_navigation_tutorial



回答3:

You can use any number of images in a sprite. Depends on your requirement.



回答4:

If done right this will be the result:

alt text http://img710.imageshack.us/img710/1429/navigx.jpg