css sprite navigation

强颜欢笑 提交于 2019-12-11 06:28:57

问题


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



来源:https://stackoverflow.com/questions/3060824/css-sprite-navigation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!