gpt4 book ai didi

javascript - 无法在图像 slider 中的点上设置圆形边框

转载 作者:太空宇宙 更新时间:2023-11-04 07:41:19 25 4
gpt4 key购买 nike

我使用了 Codepen 的幻灯片 https://codepen.io/dfitzy/pen/xZqGVo但我无法更改这些点来更改幻灯片。我想在点周围添加黑色边框。当我尝试它时,它会变成矩形。为了节省您的时间,这是带有点“a.slide_btn”的类。我知道的很少,但我无法弄清楚是什么。

$('.slider').each(function() {
var $this = $(this);
var $group = $this.find('.slide_group');
var $slides = $this.find('.slide');
var bulletArray = [];
var currentIndex = 0;
var timeout;

function move(newIndex) {
var animateLeft, slideLeft;

advance();

if ($group.is(':animated') || currentIndex === newIndex) {
return;
}

bulletArray[currentIndex].removeClass('active');
bulletArray[newIndex].addClass('active');

if (newIndex > currentIndex) {
slideLeft = '100%';
animateLeft = '-100%';
} else {
slideLeft = '-100%';
animateLeft = '100%';
}

$slides.eq(newIndex).css({
display: 'block',
left: slideLeft
});
$group.animate({
left: animateLeft
}, function() {
$slides.eq(currentIndex).css({
display: 'none'
});
$slides.eq(newIndex).css({
left: 0
});
$group.css({
left: 0
});
currentIndex = newIndex;
});
}

function advance() {
clearTimeout(timeout);
timeout = setTimeout(function() {
if (currentIndex < ($slides.length - 1)) {
move(currentIndex + 1);
} else {
move(0);
}
}, 4000);
}

$('.next_btn').on('click', function() {
if (currentIndex < ($slides.length - 1)) {
move(currentIndex + 1);
} else {
move(0);
}
});

$('.previous_btn').on('click', function() {
if (currentIndex !== 0) {
move(currentIndex - 1);
} else {
move(3);
}
});

$.each($slides, function(index) {
var $button = $('<a class="slide_btn">&bull;</a>');

if (index === currentIndex) {
$button.addClass('active');
}
$button.on('click', function() {
move(index);
}).appendTo('.slide_buttons');
bulletArray.push($button);
});

advance();
});
html, body {
background: #F7F5E6;
height: 100%;
margin: 0;
padding: 0;
width: 100%;
}

.slider {
margin: 0 auto;
width:100%;
height:100%;
}

.slide_viewer {
height:100%;
height: 340px;
overflow: hidden;
position: relative;
}

.slide_group {

height: 100%;
position: relative;
width: 100%;
}

.slide {
display: none;
height: 100%;
position: absolute;
width: 100%;
}

.slide:first-child {
height:100%;
display: block;
}

.slide:nth-of-type(1) {
height:100%;
background: #D7A151;
}

.slide:nth-of-type(2) {
height:100%;
background: #F4E4CD;
}

.slide:nth-of-type(3) {
background: #C75534;
}

.slide:nth-of-type(4) {
height:100%;
background: #D1D1D4;
}

.slide_buttons {
left: 0;
position: absolute;
right: 0;
text-align: center;
}

a.slide_btn {
color: #474544;
font-size: 42px;
margin: 0 0.175em;
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}

.slide_btn.active, .slide_btn:hover {
color: #428CC6;
cursor: pointer;
}

.directional_nav {
height: 340px;
margin: 0 auto;
max-width: 940px;
position: relative;
top: -340px;
}

.previous_btn {
bottom: 0;
left: 100px;
margin: auto;
position: absolute;
top: 0;
}

.next_btn {
bottom: 0;
margin: auto;
position: absolute;
right: 100px;
top: 0;
}

.previous_btn, .next_btn {
cursor: pointer;
height: 65px;
opacity: 0.5;
-webkit-transition: opacity 0.4s ease-in-out;
-moz-transition: opacity 0.4s ease-in-out;
-ms-transition: opacity 0.4s ease-in-out;
-o-transition: opacity 0.4s ease-in-out;
transition: opacity 0.4s ease-in-out;
width: 65px;
}

.previous_btn:hover, .next_btn:hover {
opacity: 1;
}

@media only screen and (max-width: 767px) {
.previous_btn {
left: 50px;
}
.next_btn {
right: 50px;
}
}
<div class="slider">
<div class="slide_viewer">
<div class="slide_group">
<div class="slide">
</div>
<div class="slide">
</div>
<div class="slide">
</div>
<div class="slide">
</div>
</div>
</div>
</div><!-- End // .slider -->

<div class="slide_buttons">
</div>
</div><!-- End // .directional_nav -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

最佳答案

其实里面用到的圆圈都是类似字母的符号。当您为 a.slide_btn 提供边框时,它基本上只是为 a 提供边框,它是字母(符号)的容器。实际上你有两种方法,第一种方法是以 svg 格式绘制自定义圆圈,就像 slider 中使用的下一个和上一个按钮一样。但是如果你想要一些简单的东西,你可以给包含那个圆圈的 a.slide_btn 文本阴影。

a.slide_btn {
color: #428CC6;
font-size: 200px;
text-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black;
}
<a class="slide_btn">•</a>

关于javascript - 无法在图像 slider 中的点上设置圆形边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48488650/

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