jQuery 轮播风格滑动导航菜单
我目前有一个有 2 行的导航菜单;当鼠标悬停在相关菜单项上时会出现一个顶部导航和一个子导航(全部通过 CSS 完成)。
本质上,子导航将自动填充相关项目,我想知道是否可以使用 jQuery 沿着子导航滚动?
jCarousel 似乎可以做我想做的事情(水平滚动),但是我的子导航只是一堆 href 标签, span 类中的分隔符,例如:
<ul id="topnav">
<li><a href="#" class="red">topmenu item</a>
<span>
<a href="#">submenu link 1</a> |
<a href="#" class="even">submenu link 2</a> |
<a href="#">submenu link 3</a> |
<a href="#" class="even">submenu link 4</a> |
<a href="#">submenu link 5</a> |
<a href="#" class="even">submenu link 6</a> |
<a href="#">submenu link 7</a> |
</span>
</li>
</ul>
有什么方法可以使用 jQuery 滚动我的 subnav href 链接,而不必将其转换为 HTML 到列表等?重做 CSS 会很痛苦;另外,我的子导航无论如何都会自动输出为 href 链接。
我只是希望出现一个小箭头,如果/当链接溢出时,用户可以单击并滚动到右侧。是否可以在不更改我已有的 HTML 的情况下实现这一点?
谢谢。
I currently have a navigation menu with 2 lines; a topnav and a subnav which appears when hovering over the relevant menu item (all done via done via CSS).
Essentially, the subnav will be automatically populated with relevant items, and I was wondering if it is possible to scroll along the subnav using jQuery?
jCarousel appears to do what I want (scroll horizontally), however my subnav is simply a bunch of href tags and seperators within a span class, e.g.:
<ul id="topnav">
<li><a href="#" class="red">topmenu item</a>
<span>
<a href="#">submenu link 1</a> |
<a href="#" class="even">submenu link 2</a> |
<a href="#">submenu link 3</a> |
<a href="#" class="even">submenu link 4</a> |
<a href="#">submenu link 5</a> |
<a href="#" class="even">submenu link 6</a> |
<a href="#">submenu link 7</a> |
</span>
</li>
</ul>
Is there any way I can use jQuery to scroll my subnav href links, without having to convert it to a HTML to a list etc.? It would be a pain having to redo the CSS; plus my subnav is automatically outputted as href links anyway.
I simply would like to have a little arrow appear which would allow users to click and scroll to the right if/when the links overflowed. Is this possible without having to change the HTML I already have?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论