Nivo Slider:Skype.com 轮播效果 - 根据 CurrentSlide 更改导航的 CSS

发布于 2024-12-21 14:00:53 字数 1871 浏览 5 评论 0原文

我一直在尝试创建一个基于 Nivo Slider 的滑块,其外观和功能类似于 中的轮播http://www.skype.com/intl/en/home

我已查看 AshfameChris_Mac,但是周末的大部分时间我都在兜圈子。现在回到第一个方面,从基础开始。

到目前为止,我已经设法使导航正常工作,以便特定导航项上的 mouseenter 触发 nivo-controlNav 显示正确的幻灯片并暂停滑块:

<script type="text/javascript">    
$("ul#nav_1").mouseenter(
    function () {
       $(".nivo-controlNav a:nth-child(2)").click();
       $('#slider').data('nivoslider').stop();
    });
</script>

我还为导航项(1、2、3 等)创建了一个后续的 mouseleave 函数。)

<script type="text/javascript">
$("ul#nav_1,ul#nav_2,ul#nav_3").mouseleave(
     function () {
       $('#slider').data('nivoslider').start();
      });
    </script>

我现在陷入了非鼠标事件进入的部分。当滑块加载时,它应该更新导航 CSS 以突出显示当前选定的导航项。这是我所得到的(我知道的不多,但我正在努力)。

<script type="text/javascript">
$(window).load(function() {
    $('#slider').nivoSlider({
       beforeChange: function(){ // this function should load css styles
          var slide_num = $('#slider').data('nivo:vars').currentSlide;
          function scrollBannerCss () {
             if (slide_num == 1) {
               $("ul#nav_1").css("backgound-color", "blue");
                 }
           }
       },
       afterChange: function(){ // this function should unload css styles
    });
 });
</script>

然后是简单的 html 导航菜单:

<ul id="nav">
   <li id="nav_1">button 1</li>
   <li id="nav_2">button 2</li>
   <li id="nav_3">button 3</li>
</ul>

任何帮助/想法/思考将不胜感激!

I have been trying to create a slider based on Nivo Slider that looks and functions similar to the Carousel found at http://www.skype.com/intl/en/home

I have viewed questions by Ashfame and by Chris_Mac, however I have been going round in circles for most of the weekend. Now back at square one and starting from the basics.

Thus far I have managed to get the navigation working such that mouseenter on a particular nav item triggers nivo-controlNav to display the correct slide and pauses the slider:

<script type="text/javascript">    
$("ul#nav_1").mouseenter(
    function () {
       $(".nivo-controlNav a:nth-child(2)").click();
       $('#slider').data('nivoslider').stop();
    });
</script>

I also created a subsequent mouseleave function for the nav items (1,2,3 etc.)

<script type="text/javascript">
$("ul#nav_1,ul#nav_2,ul#nav_3").mouseleave(
     function () {
       $('#slider').data('nivoslider').start();
      });
    </script>

I'm now stuck at the part where non-mouse events come in. When the slider loads it should update the nav css to highlight the current nav item selected. Here is what I've got (not a lot I know, but I'm trying).

<script type="text/javascript">
$(window).load(function() {
    $('#slider').nivoSlider({
       beforeChange: function(){ // this function should load css styles
          var slide_num = $('#slider').data('nivo:vars').currentSlide;
          function scrollBannerCss () {
             if (slide_num == 1) {
               $("ul#nav_1").css("backgound-color", "blue");
                 }
           }
       },
       afterChange: function(){ // this function should unload css styles
    });
 });
</script>

Then the simple html nav menu:

<ul id="nav">
   <li id="nav_1">button 1</li>
   <li id="nav_2">button 2</li>
   <li id="nav_3">button 3</li>
</ul>

Any help/ideas/musings would be hugely appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若无相欠,怎会相见 2024-12-28 14:00:53

我知道这有点旧,但您可能想看看 http://www.agilecarousel.com/

http://www.agilecarousel.com/flavor_3.htm 正是您所说的,考虑到今天的 Skype.com 与您两个月前看到的情况相同。

I know this is a little old but you may want to look at http://www.agilecarousel.com/.

http://www.agilecarousel.com/flavor_3.htm is the exact thing you are talking about, considering skype.com today is the same thing you saw two months ago.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文