简体   繁体   English

如何显示下一张和/或上一张幻灯片的一些像素?

[英]How to show the some pixels of the next slide and or previous slide?

I have created a very simple carousel slider, that you can check out here: 我创建了一个非常简单的轮播滑块,您可以在此处查看:

http://codepen.io/anon/pen/QjgvPj http://codepen.io/anon/pen/QjgvPj

Now I want to see some pixels of the next list item if the first slide is active, or if the second list item is active, I want to see some of the pixels from the previous one. 现在,如果第一个幻灯片处于活动状态,或者第二个列表项处于活动状态,我想查看下一个列表项的一些像素,我想查看上一个幻灯片的一些像素。

So this would look something like this, if your on the first slide: 因此,如果您在第一张幻灯片上,它看起来像这样:

右侧的红色条表示下一张幻灯片的一些像素

The red bar on the right represent some of the pixels of the next slide 右边的红色条代表下一张幻灯片的一些像素

And if you are somewhere in the middle of the slides, you will see left and right the next and previous slide: 如果您位于幻灯片的中间,您将在下一张和上一张幻灯片的左侧和右侧看到:

在此处输入图片说明

The two red bars on each side represents the previous and next slide 两侧的两个红色条形代表上一张和下一张幻灯片

My basic setup is: HTML: 我的基本设置是:HTML:

<div class="inner">
    <ul>
      <li>
        <a href="">
          <div>
            <img src="http://www.placehold.it/1000x420">
            <div><span>Spring Mountains</span></div>
          </div>
        </a>
      </li>
       <li>
        <a href="">
          <div>
            <img src="http://www.placehold.it/1000x420">
            <div><span>I Took this Yosemite</span></div>
          </div>
        </a>
      </li>
       <li>
        <a href="">
          <div>
            <img src="http://www.placehold.it/1000x420">
            <div><span>I Took El Capitan</span></div>
          </div>
        </a>
      </li>
      <li>
        <a href="">
          <div>
            <img src="http://www.placehold.it/1000x420">
            <div><span>Fourth</span></div>
          </div>
        </a>
      </li>
    </ul>  
  </div>

How do I achieve this? 我该如何实现? I look out for your answer. 我很期待你的回答。 Thank you in advance. 先感谢您。

UPDATE: This time with colorful photos! 更新:这次有彩色照片!

http://codepen.io/anon/pen/QjgvPj http://codepen.io/anon/pen/QjgvPj

http://codepen.io/anon/pen/BoZZGQ http://codepen.io/anon/pen/BoZZGQ

I add a class for the selected li , to change the z-index property and define who overlap the other. 我为选定的li添加一个类,以更改z-index属性并定义谁与另一个重叠。

javascirpt : javascirpt:

  var current = $('#carousel ul li').get(index);
  current.classList.add('active');
  if(lastOne)
    lastOne.classList.remove('active');
  lastOne = current;

css: CSS:

#carousel ul li{
  z-index: 1;
}
#carousel ul li.active{
  z-index: 0;
}

add negative margin to get the overlap: 添加负边距以获得重叠:

#carousel ul li{
  margin-right: -50px
}

And update the offset : $('#carousel ul').animate({'margin-left': '-' + index*950}); 并更新偏移量: $('#carousel ul').animate({'margin-left': '-' + index*950});

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

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