css 如何调整我的图片轮播之间的空间?

oalqel3c  于 2023-04-08  发布在  其他
关注(0)|答案(1)|浏览(110)

我试着从我的旋转木马调整我的图像之间的空间,但我不知道我怎么能做到这一点。我已经尝试了很多事情,但不工作,除了打破我的旋转木马
下面是我的codepen: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>
wqsoz72f

wqsoz72f1#

要增加间距u需要改变transform3d值。活动图像具有此值transform: translate3d(0%, 0, 0px);。此值包含3轴x, y, z。在您的情况下,重要的值是第一个因此,当前活动图像旁边的图像具有值+/- 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>

相关问题