简体   繁体   中英

Background-position in css

Can we use more than 2 images for single navigation. That means when we hover on that image it will shows 6 different images. Is it possible to make for a single navigation image? If possible means how?

I think you are all understand this

alt text http://img714.imageshack.us/img714/2786/mubeen.gif

If I understood you correctly, you want to continously change the position of your background image while you hover over one button.

If that's right, then I suggest making a static image as background image and changing the image to a GIF animated image on hover

You can (at the moment - cross browser) only set one bg image on an element. If you want to change it on hover or whatever, just add an a -tag with href set on # :

<a class="img" id="thatoneimg" href="#"></a>

And then in the css:

a.img {
  width: 100px;
  height: 100px;
}
a#thatoneimg {
  backround-image: url(staticimg.jpg);
}
a#thatoneimg:hover {
  backround-image: url(movingimg.gif);
}

That should work cross browser. You need the a -tag for it to work in IE.

Edit: As Starx said, just make the second image a .gif with an animation. It will not use sprites but it will work.

如果我提出的问题正确,则有可能,但是您将必须具有6个不同的HTML元素才能在6个不同位置包含背景图像。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM