K
K
ksanka1112020-11-04 15:21:37
css
ksanka111, 2020-11-04 15:21:37

Slider in HTML and CSS?

There is a slider. You need to add captions under the pictures so that they also scroll with them.
Everything needs to be done in HTML and CSS

.slider-wrap
          input#slide1(type='radio' name='point' checked='')
          input#slide2(type='radio' name='point')
          input#slide3(type='radio' name='point')
          .slider
            .slides.slide1
            .slides-text
              p Спасибо, что даете почувствовать себя сводобными! Ходили дважды, и каждый раз заряжались энергией на год вперед. Отдельное спасибо гиду Михаилу!
            .slides.slide2
            .slides.slide3
          .controls
            label(for='slide1')
            label(for='slide2')
            label(for='slide3')
<code lang="css">
.slider-wrap
  width: 924px
  height: 362px
  position: relative
  margin: 0 auto

  h2
    margin-bottom: 47px

  input
    display: none

  .slider
    height: 100%
    overflow: hidden
    position: relative
    width: 100%

    .slides
      height: inherit
      position: absolute
      width: inherit
      background-size: 100% auto
      z-index: 0
      opacity: 0
      //transform: scale(1.5)
      transition: transform ease-in-out .5s, opacity ease-in-out .5s
      width: 96px
      height: 96px
      left: 414px
      border-radius: 50%

    .slide1
      background-image: url(../images/[email protected])

    .slide2
      background-image: url(../images/img-blog3.jpg)

    .slide3
      background-image: url(../images/[email protected])

  .controls
    display: flex
    justify-content: center

  label
    cursor: pointer
    display: inline-block
    height: 8px
    margin-right: 12px
    position: relative
    width: 8px
    border-radius: 50%
    transition: background ease-in-out .5s
    background: rgba(255, 255, 255, 0.5)

label:last-child
  margin-right: 0

#slide1:checked ~ .controls label:nth-of-type(1),
#slide2:checked ~ .controls label:nth-of-type(2),
#slide3:checked ~ .controls label:nth-of-type(3)
  background: #ffffff

  label:after
    content: " "
    display: block
    height: 12px
    left: -4px
    position: absolute
    top: -4px
    width: 12px
    border-radius: 50%
    background: rgba(255, 255, 255, 0.5)

#slide1:checked ~ .slider > .slide1,
#slide2:checked ~ .slider > .slide2,
#slide3:checked ~ .slider > .slide3,
#slide4:checked ~ .slider > .slide4,
#slide5:checked ~ .slider > .slide5
  opacity: 1
  z-index: 1
  transform: scale(1)
</code>

Here is an example of how it should be:
https://habrastorage.org/webt/5f/a2/9d/5fa29d82ee9...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ksanka111, 2020-11-04
@ksanka111

I found a solution
I tweaked the code a little and added:

<div class="slider-wrap">
          <input id="slide1" type="radio" name="point" checked="">
          <input id="slide2" type="radio" name="point">
          <input id="slide3" type="radio" name="point">
          <div class="slider">
            <div class="slides slide1"></div>
            <div class="slides-text1">
              <p>Спасибо, что даете почувствовать себя сводобными! Ходили дважды, и каждый раз заряжались энергией на год вперед. Отдельное спасибо гиду Михаилу!</p>
              <h5>Cофия</h5>
            </div>
            <div class="slides slide2"></div>
            <div class="slides-text2">
              <p>Ходили дважды, и каждый раз заряжались энергией на год вперед. Спасибо, что даете почувствовать себя сводобными! Отдельное спасибо гиду Михаилу!</p>
              <h5>Дмитрий</h5>
            </div>
            <div class="slides slide3"></div>
            <div class="slides-text3">
              <p>Отдельное спасибо гиду Михаилу! Ходили дважды, и каждый раз заряжались энергией на год вперед. Отдельное спасибо гиду Михаилу! Спасибо, что даете почувствовать себя сводобными!</p>
              <h5>Егор</h5>
            </div>
          </div>
          <div class="controls">
            <label for="slide1"></label>
            <label for="slide2"></label>
            <label for="slide3"></label>
          </div>
        </div>
      </div>

.slider-wrap {
  width: 924px;
  height: 300px;
  position: relative;
  margin: 0 auto; }
  .slider-wrap h2 {
    margin-bottom: 47px; }
  .slider-wrap input {
    display: none; }
  .slider-wrap .slider {
    height: 100%;
    overflow: hidden;
    position: relative;
    width: 100%; }
    .slider-wrap .slider .slides {
      height: inherit;
      position: absolute;
      width: inherit;
      background-size: 100% auto;
      z-index: 0;
      opacity: 0;
      transition: transform ease-in-out .5s, opacity ease-in-out .5s;
      width: 96px;
      height: 96px;
      left: 414px;
      border-radius: 50%;
      top: 0; }
    .slider-wrap .slider .slide1 {
      background-image: url(../images/[email protected]); }
    .slider-wrap .slider .slide2 {
      background-image: url(../images/img-blog3.jpg); }
    .slider-wrap .slider .slide3 {
      background-image: url(../images/[email protected]); }
  .slider-wrap .controls {
    display: flex;
    justify-content: center; }
  .slider-wrap label {
    cursor: pointer;
    display: inline-block;
    height: 8px;
    margin-right: 12px;
    position: relative;
    width: 8px;
    border-radius: 50%;
    transition: background ease-in-out .5s;
    background: rgba(255, 255, 255, 0.5); }

label:last-child {
  margin-right: 0; }

#slide1:checked ~ .controls label:nth-of-type(1),
#slide2:checked ~ .controls label:nth-of-type(2),
#slide3:checked ~ .controls label:nth-of-type(3) {
  background: #ffffff; }
  #slide1:checked ~ .controls label:nth-of-type(1) label:after,
  #slide2:checked ~ .controls label:nth-of-type(2) label:after,
  #slide3:checked ~ .controls label:nth-of-type(3) label:after {
    content: " ";
    display: block;
    height: 12px;
    left: -4px;
    position: absolute;
    top: -4px;
    width: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5); }

#slide1:checked ~ .slider > .slide1,
#slide2:checked ~ .slider > .slide2,
#slide3:checked ~ .slider > .slide3 {
  opacity: 1;
  z-index: 1;
  transform: scale(1); }

.slides-text1,
.slides-text2,
.slides-text3 {
  text-align: center;
  position: absolute;
  top: 126px;
  opacity: 0;
  z-index: 0;
  transition: transform ease-in-out .5s, opacity ease-in-out .5s;
  position: absolute;
  top: 126px;
  width: 100%; }
  .slides-text1 p,
  .slides-text2 p,
  .slides-text3 p {
    font-size: 24px;
    line-height: 32px;
    color: #FFFFFF;
    margin-bottom: 32px; }
  .slides-text1 h5,
  .slides-text2 h5,
  .slides-text3 h5 {
    font-weight: 600;
    font-size: 16px;
    line-height: 16px;
    color: #FFB800; }

#slide1:checked ~ .slider > .slides-text1,
#slide2:checked ~ .slider > .slides-text2,
#slide3:checked ~ .slider > .slides-text3 {
  opacity: 1;
  z-index: 1; }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question