简体   繁体   English

更改页面滚动上的活动导航图像?

[英]Change Active Navigation Image on Page Scroll?

I'm attempting to reproduce a similar navigation bar to what's used on this website: http://www.julisudi.com/ . 我试图重现与该网站上使用的导航栏相似的网址: http : //www.julisudi.com/ The main effect I'm looking for is to have each image become active when the correct anchor is reached on the page. 我要寻找的主要效果是在页面上到达正确的锚点后使每个图像都处于活动状态。

I have seen this done with text via http://jsfiddle.net/Vandeplas/up4nu/150/ I have also created some images and use the following CSS to reproduce the 'change colour' effect when the image becomes active: 我已经通过http://jsfiddle.net/Vandeplas/up4nu/150/通过文本完成了此操作,我还创建了一些图像,并在图像变为活动状态时使用以下CSS来再现“改变颜色”效果:

#mainmenu a img {
     position: relative;
     margin-bottom: -30px;
     margin-top: 5px;
}

#mainmenu a img:hover, #mainmenu a img.active{ 
     top: -31px;
}

The problem I'm having is replacing code in the jfiddle to make it work with images rather than text. 我遇到的问题是替换jfiddle中的代码以使其适用于图像而不是文本。 If anyone could help that would be great! 如果有人可以帮助,那就太好了!

You can use the id on any elements, it can be a <p> or an <img> . 您可以在任何元素上使用id ,它可以是<p><img>

In the menu, it doesn't matter if <a> is filled with text , img or both. 在菜单中, <a>是否填充text, img或两者都没关系。

http://jsfiddle.net/up4nu/2682/ http://jsfiddle.net/up4nu/2682/

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

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