简体   繁体   English

将背景图像滑动到图像链接后面

[英]Slide a background-image behind an image link

So, i have this html webpage with a menu. 所以,我有这个带有菜单的html网页。 I have coded the menu as a list with 3 links. 我已经将菜单编码为带有3个链接的列表。

The menu consists of Illustrator png images : home, contact, etc. What i want to achieve is that a certain color slides from the left when you hover on the links. 菜单包含Illustrator png图像:家庭,联系人等。我要实现的是,当您将鼠标悬停在链接上时,某些颜色会从左侧滑动。 This certain color is also an Illustrator image. 此特定颜色也是Illustrator图像。

I was able to do this (with a tutorial) with a simple plain text for the menu, the image for the background slide and jQuery: jQuery buttons , but I want to do this with 2 images. 我能够使用菜单的简单纯文本,背景幻灯片的图像和jQuery: jQuery button (使用教程)来完成此操作,但是我想使用2张图像来完成此操作。

Am i explaining myself correctly? 我在正确地解释自己吗? How can I attempt to do this? 我该怎么做呢?

There are a few ways you can achieve this, here are 3. 有几种方法可以实现这一目标,这里是3。

1) Include the transparent image in your background image sprite. 1)在背景图像精灵中包含透明图像。 So you're combining both images and using it as a single background image. 因此,您要合并两个图像并将其用作单个背景图像。 Then you just position the background image accordingly. 然后,您只需定位背景图像即可。 If you're not familiar with sprites, here is a post that discusses them: CSS Sprite Button 如果您不熟悉Sprite ,可以在这里讨论它们: CSS Sprite Button

2) Hard code the image into your link and use css to generate the background color. 2)将图片硬编码到您的链接中,然后使用CSS生成背景色。 That way you don't have to use a separate image. 这样,您不必使用单独的图像。 For example: a:hover { background: #f00; 例如:a:hover {background:#f00; } }

3) Hard code the image into your link and use a background image to achieve the hover effect. 3)将图片硬编码到您的链接中,并使用背景图片来达到悬停效果。 I don't recommend this because it causes your links to become unsearchable and unselectable. 我不建议这样做,因为它会使您的链接变得不可搜索和无法选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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