开发者

css sprite navigation

Is it possible to use three images in CSS spri开发者_C百科te navigation?

This may be like this

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

If its possible what will be the result?


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


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.


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


If done right this will be the result:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜