简体   繁体   English

图像悬停居中,而不是相对于悬停的链接

[英]Image hover is centred and not relative to link that is being hovered over

On a website I'm working on I got images inside a container that need to appear over the text on hover. 在我正在处理的网站上,我将图像保存在一个容器内,该图像需要在悬停时显示在文字上方。 This works smooth BUT.. 这样可以顺利运行,但..

Whenever an image appears it stays in the same location as the previous hover. 每当出现图像时,它就会与上一个悬停在相同的位置。 I am trying to make the images only appear over the link it is associated with but it won't work. 我正在尝试使图像仅显示在与之关联的链接上,但无法正常工作。

I have some JavaScript running to randomize the link colors. 我有一些JavaScript正在运行以随机化链接颜色。

You can find the webpage in action over here: http://bravenewfashion.com/menu.html Its on the tab titled 'Biology meets Fashion' 您可以在以下位置找到正在使用的网页: http : //bravenewfashion.com/menu.html它在“生物学与时尚相遇”选项卡上

Thanks for the working example. 感谢您的工作示例。 If you nest the image inside of the a tag, it will automatically position itself next to the link. 如果你窝的图像a标签,它会自动将自己旁边放置链接。 You can then add some rules for top and left to position them over the link like your website does now. 然后,您可以为topleft添加一些规则,以将其放在链接上,就像您的网站现在一样。

Working JSFiddle Here 在这里工作的JSFiddle

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

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