gpt4 book ai didi

javascript - 在 slider 中居中 ResponsiveSlides 导航箭头?

转载 作者:行者123 更新时间:2023-12-02 06:34:43 24 4
gpt4 key购买 nike

我的网站上有一个 ResponsiveSlides slider ,我试图让上一个/下一个导航箭头在 slider 的左右边缘垂直居中。

当我调整浏览器大小时,它们会四处移动,向右/下一个箭头似乎悬在 slider 外几个像素,并且在 480px 断点周围发生了一些奇怪的事情(一旦你比 480px 小一点点, slider 比下面的列宽一点;而且,箭头在屏幕下方更远的地方结束)。

直播可以看到here

js

<script src="js/responsiveslides.min.js"></script>
<script>
$(function() {
$("#slider").responsiveSlides({
auto: true,
pager: false,
nav: true,
});
});
</script>

html

<div class="section group">
<div class="col span_3_of_3">
<ul id="slider">
<li id="1"><img src="assets/slider/buzz-covers.jpg" alt="buzz covers"></li>
<li id="2"><img src="assets/slider/slab-happy.png" alt="slab happy"></li>
<li id="3"><img src="assets/slider/gridbook.jpg" alt="gridbook"></li>
<li id="4"><img src="assets/slider/ninth-spread.jpg" alt="ninth letter"></li>
<li id="5"><img src="assets/slider/slinkster.jpg" alt="slinkster"></li>
<li id="6"><img src="assets/slider/buzz-spread.jpg" alt="buzz spread"></li>
</ul>
</div>
</div>

css(不确定哪些位与我正在做的有关,所以这里是我的样式表中与 slider 相关的所有内容)

.rslides {
position: relative;
list-style: none;
overflow: hidden;
width: 100%;
padding: 0;
margin: 1.5em 0 0 0;
background-color: #f7f7f7;
}

.rslides li {
-webkit-backface-visibility: hidden;
position: absolute;
display: none;
width: 100%;
left: 0;
top: 0;
}

.rslides li:first-child {
position: relative;
display: block;
float: left;
}

.rslides img {
display: block;
height: auto;
float: left;
width: 100%;
border: 0;
}

.rslides1_nav {
position: absolute;
-webkit-tap-highlight-color: rgba(0,0,0,0);
top: 50%;
left: 0;
z-index: 99;
opacity: 0.7;
text-indent: -9999px;
overflow: hidden;
text-decoration: none;
height: 61px;
width: 38px;
background: transparent url("themes.gif") no-repeat left top;
margin-top: -45px;
}

.rslides1_nav:active {
opacity: 1.0;
}

.rslides1_nav.next {
left: auto;
background-position: right top;
right: 0;
}

.rslides1_nav:focus {
outline: none;
}

.rslides_tabs {
margin-top: 10px;
text-align: center;
}

.rslides_tabs li {
display: inline;
float: none;
_float: left;
*float: left;
margin-right: 5px;
}

.rslides_tabs a {
text-indent: -9999px;
overflow: hidden;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
background: #ccc;
background: rgba(0,0,0, .2);
display: inline-block;
_display: block;
*display: block;
-webkit-box-shadow: inset 0 0 2px 0 rgba(0,0,0,.3);
-moz-box-shadow: inset 0 0 2px 0 rgba(0,0,0,.3);
box-shadow: inset 0 0 2px 0 rgba(0,0,0,.3);
width: 9px;
height: 9px;
}

.rslides_tabs .rslides_here a {
background: #222;
background: rgba(0,0,0, .8);
}

最佳答案

如 Varinder 所述,将 #slider 的父级 (.col.span_3_of_3) 和上一个/下一个链接设置为 relative 只能解决部分问题。

<div class="col span_3_of_3" style="position: relative;">
<ul id="slider" class="rslides rslides1">
<li id="rslides1_s0" class="" style="display: block; float: none; position: absolute; opacity: 0; z-index: 1; -webkit-transition: opacity 500ms ease-in-out; transition: opacity 500ms ease-in-out;">
<img src="assets/slider/buzz-covers.jpg" alt="buzz covers">
</li>
<li id="rslides1_s1" style="float: left; position: relative; opacity: 1; z-index: 2; display: list-item; -webkit-transition: opacity 500ms ease-in-out; transition: opacity 500ms ease-in-out;" class="rslides1_on">
<img src="assets/slider/slab-happy.png" alt="slab happy">
</li>
<li id="rslides1_s2" style="float: none; position: absolute; opacity: 0; z-index: 1; display: list-item; -webkit-transition: opacity 500ms ease-in-out; transition: opacity 500ms ease-in-out;" class="">
<img src="assets/slider/gridbook.jpg" alt="gridbook">
</li>
<li id="rslides1_s3" style="float: none; position: absolute; opacity: 0; z-index: 1; display: list-item; -webkit-transition: opacity 500ms ease-in-out; transition: opacity 500ms ease-in-out;" class="">
<img src="assets/slider/ninth-spread.jpg" alt="ninth letter">
</li>
<li id="rslides1_s4" style="float: none; position: absolute; opacity: 0; z-index: 1; display: list-item; -webkit-transition: opacity 500ms ease-in-out; transition: opacity 500ms ease-in-out;" class="">
<img src="assets/slider/slinkster.jpg" alt="slinkster">
</li>
<li id="rslides1_s5" style="float: none; position: absolute; opacity: 0; z-index: 1; display: list-item; -webkit-transition: opacity 500ms ease-in-out; transition: opacity 500ms ease-in-out;" class="">
<img src="assets/slider/buzz-spread.jpg" alt="buzz spread">
</li>
</ul>
<a href="#" class="rslides_nav rslides1_nav prev">Previous</a><a href="#" class="rslides_nav rslides1_nav next">Next</a>
</div>

下一部分是将“.rslides_nav”上的 margin-top 设置为 -19.5px 以使幻灯片导航按钮完全垂直居中。

这个解决方案源于这样一个事实,即当浏览器宽度小于 420 像素时,您已经为那些使按钮仍然略微不对齐的链接预定义了 margin-top。

所以您的问题的解决方案是使用以下 CSS

.rslides_nav{
margin-top:-19.5px !important;
}
.col.span_3_of_3{
position:relative;
}

Side-by-side comparison

Demo

关于javascript - 在 slider 中居中 ResponsiveSlides 导航箭头?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22266435/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com