简体   繁体   English

在幻灯片上自动定位箭头

[英]Automatically positioning arrows on slideshow

I'm currently coding a jQuery slideshow effect and need a bit of help. 我目前正在编写jQuery幻灯片效果,需要一些帮助。 I have all of the sideshow functionality working properly, my only problem is that I want to have my navigation arrows to be automatically positioned on either side of the slideshow box (960px, centered on the screen). 我有所有的sideshow功能正常工作,我唯一的问题是我想让我的导航箭头自动定位在幻灯片显示框的两侧(960px,以屏幕为中心)。

The end product should be something like Kriesi does here: http://www.kriesi.at/themes/upscale/ 最终产品应该像Kriesi在这里做的那样: http ://www.kriesi.at/themes/upscale/

I've looked at his code, but can't quite figure it out. 我已经查看了他的代码,但无法弄明白。 Any help would be appreciated! 任何帮助,将不胜感激!

Thanks! 谢谢!

Arrows are situated in . 箭头位于。 That block is positioned as absolute with top value as 50% - 12px (margin-top: -12px); 该块定位为绝对值,最高值为50% - 12px(margin-top:-12px);

Then, there is a list which contains images and other data and affect height of it's parent . 然后,有一个列表,其中包含图像和其他数据,并影响其父级的高度。

So, basically, in the code, when user clicks on an arrow, jQUery probabaly uses outerHeight() to get height of li elements in and then uses animate() to change height of the which affects height of the and that in it's turn smoothly changes position of the arrows. 所以,基本上,在代码中,当用户点击一个箭头时,jQUery probabaly使用outerHeight()来获取li元素的高度,然后使用animate()来改变影响高度的高度,并在其中顺利转动改变箭头的位置。


Personally, i think it's a bad designing when arrows change it's position. 就个人而言,我认为当箭头改变它的位置时,这是一个糟糕的设计。 Very annoying when you have to move mouse up and down every time you want to see the next slide. 每次想要查看下一张幻灯片时,必须上下移动鼠标,这非常烦人。

I don't understand what you mean by "I can't quite figure out how to initially position them over the slideshow... If I do it in CSS, then it won't work on all screen resolutions."...? 我不明白你的意思是“我无法弄清楚如何将它们放在幻灯片上...如果我在CSS中这样做,那么它将不适用于所有屏幕分辨率。”...... ?

If you position the arrows relative to the slideshow, there will be no issue. 如果您相对于幻灯片放置箭头,则没有问题。 For example to place them at the top left and top right corners, include the following in your styles: 例如,要将它们放在左上角和右上角,请在样式中包含以下内容:

#slideshowcontainer{
   width: 960px; 
   height: 400px;
   position: relative;
}
#leftarrow{
   position: absolute;
   top: 0px;
   left: -40px; /* position the arrow 40px to the left of the slideshow */
}
#rightarrow{
   position: absolute;
   top: 0px;
   right: -40px; /* position the arrow 40px to the right of the slideshow */
}

Obviously you will need to adjust the values to suit, depending on the size of your arrows and where you want them etc 显然,您需要调整值以适应,具体取决于箭头的大小和您想要的位置等

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

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