如何调整我的图像旋转木马之间的空间?



我试图调整我的图像之间的空间从我的轮播,但我不知道我怎么能做到这一点。我已经尝试了很多东西,但除了打破我的旋转木马之外,都不起作用

这是我的合作伙伴:https://codepen.io/Softee/pen/MWPgbyw

#slider_perso {
position: relative;
width: 20%;
height: 32vw;
margin: 150px auto;
font-family: 'Helvetica Neue', sans-serif;
perspective: 1500px;
transform-style: preserve-3d;
}
input[type=radio] {
position: relative;
top: 108%;
left: 50%;
width: 18px;
height: 18px;
margin: 0 15px 0 0;
opacity: 0.4;
transform: translateX(-83px);
cursor: pointer;
}
input[type=radio]:checked {
opacity: 1;
}
#slider_perso label,
#slider_perso label img {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
color: white;
font-size: 70px;
font-weight: bold;
border-radius: 25px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: transform 500ms ease;
}
#im1:checked~#slide1,
#im2:checked~#slide2,
#im3:checked~#slide3,
#im4:checked~#slide4,
#im5:checked~#slide5 {
box-shadow: 0 13px 26px rgba(0, 0, 0, 0.3), 0 12px 6px rgba(0, 0, 0, 0.2);
transform: translate3d(0%, 0, 0px);
}
#im1:checked~#slide2,
#im2:checked~#slide3,
#im3:checked~#slide4,
#im4:checked~#slide5,
#im5:checked~#slide1 {
box-shadow: 0 6px 10px rgba(0, 0, 0, 0.3), 0 2px 2px rgba(0, 0, 0, 0.2);
transform: translate3d(20%, 0, -100px);
}
#im1:checked~#slide3,
#im2:checked~#slide4,
#im3:checked~#slide5,
#im4:checked~#slide1,
#im5:checked~#slide2 {
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
transform: translate3d(40%, 0, -250px);
}
#im1:checked~#slide5,
#im2:checked~#slide1,
#im3:checked~#slide2,
#im4:checked~#slide3,
#im5:checked~#slide4 {
box-shadow: 0 6px 10px rgba(0, 0, 0, 0.3), 0 2px 2px rgba(0, 0, 0, 0.2);
transform: translate3d(-20%, 0, -100px);
}
#im1:checked~#slide4,
#im2:checked~#slide5,
#im3:checked~#slide1,
#im4:checked~#slide2,
#im5:checked~#slide3 {
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
transform: translate3d(-40%, 0, -250px);
}
<section id="slider_perso">
<input type="radio" name="slider" id="im1">
<input type="radio" name="slider" id="im2" checked>
<input type="radio" name="slider" id="im3">
<label for="im1" id="slide1"><img src="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg" alt=""></label>
<label for="im2" id="slide2"><img src="https://thumbs.dreamstime.com/b/beautiful-sunset-over-water-tree-silhouette-nature-landscape-amazing-orange-yellow-sky-night-scene-wallpaper-birds-flying-154424473.jpg" alt=""></label>
<label for="im3" id="slide3"><img src="https://thumbs.dreamstime.com/b/spectrum-sunset-silhouette-background-trees-beautiful-color-sky-135233556.jpg" alt=""></label>
</section>

要增加间距,您需要更改transform3d的值。活动镜像的值为transform: translate3d(0%, 0, 0px);。该值包含3轴x, y, z。在您的例子中,重要的值是第一个(x轴)。因此,当前活动图像旁边的图像具有+/- 20%+/- 40%的值(负值在左侧,正值在右侧)。调整这些值,间距会增大。

PS:请记住,值是双倍的,所以20/40,30/60,40/80等

#slider_perso {
position: relative;
width: 20%;
height: 32vw;
margin: 150px auto;
font-family: 'Helvetica Neue', sans-serif;
perspective: 1500px;
transform-style: preserve-3d;
}
input[type=radio] {
position: relative;
top: 108%;
left: 50%;
width: 18px;
height: 18px;
margin: 0 15px 0 0;
opacity: 0.4;
transform: translateX(-83px);
cursor: pointer;
}
input[type=radio]:checked {
opacity: 1;
}
#slider_perso label,
#slider_perso label img {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
color: white;
font-size: 70px;
font-weight: bold;
border-radius: 25px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: transform 500ms ease;
}
#im1:checked~#slide1,
#im2:checked~#slide2,
#im3:checked~#slide3,
#im4:checked~#slide4,
#im5:checked~#slide5 {
box-shadow: 0 13px 26px rgba(0, 0, 0, 0.3), 0 12px 6px rgba(0, 0, 0, 0.2);
transform: translate3d(0%, 0, 0px);
}
#im1:checked~#slide2,
#im2:checked~#slide3,
#im3:checked~#slide4,
#im4:checked~#slide5,
#im5:checked~#slide1 {
box-shadow: 0 6px 10px rgba(0, 0, 0, 0.3), 0 2px 2px rgba(0, 0, 0, 0.2);
transform: translate3d(30%, 0, -100px);
}
#im1:checked~#slide3,
#im2:checked~#slide4,
#im3:checked~#slide5,
#im4:checked~#slide1,
#im5:checked~#slide2 {
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
transform: translate3d(60%, 0, -250px);
}
#im1:checked~#slide5,
#im2:checked~#slide1,
#im3:checked~#slide2,
#im4:checked~#slide3,
#im5:checked~#slide4 {
box-shadow: 0 6px 10px rgba(0, 0, 0, 0.3), 0 2px 2px rgba(0, 0, 0, 0.2);
transform: translate3d(-30%, 0, -100px);
}
#im1:checked~#slide4,
#im2:checked~#slide5,
#im3:checked~#slide1,
#im4:checked~#slide2,
#im5:checked~#slide3 {
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
transform: translate3d(-60%, 0, -250px);
}
<section id="slider_perso">
<input type="radio" name="slider" id="im1">
<input type="radio" name="slider" id="im2" checked>
<input type="radio" name="slider" id="im3">
<label for="im1" id="slide1"><img src="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg" alt=""></label>
<label for="im2" id="slide2"><img src="https://thumbs.dreamstime.com/b/beautiful-sunset-over-water-tree-silhouette-nature-landscape-amazing-orange-yellow-sky-night-scene-wallpaper-birds-flying-154424473.jpg" alt=""></label>
<label for="im3" id="slide3"><img src="https://thumbs.dreamstime.com/b/spectrum-sunset-silhouette-background-trees-beautiful-color-sky-135233556.jpg" alt=""></label>
</section>

相关内容

  • 没有找到相关文章

最新更新