D
D
Dymok2018-02-23 22:44:02
css
Dymok, 2018-02-23 22:44:02

How to implement a smooth change of background images?

I'm trying to make a layout that has a slider with images in the background. I did everything, but it's not possible to properly implement the change of images, that's what we have at the moment .
I want one image to dissolve into another. I tried to do it through opacity, but then the entire content of the block disappears.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stepan Krapivin, 2018-02-23
@UnluckySerivelha

It is better to do not change the background of one block, but several blocks, each with a unique background. And hide and display blocks to do through a smooth change of opacity.
Like this:

<section id="slider">
  <div class="slider__item" style="background-image: url("../slider/img/intro-slide-1.jpg"); opacity: 0">
  <div class="slider__item" style="background-image: url("../slider/img/intro-slide-2.jpg"); opacity: 1">
  <div class="slider__item" style="background-image: url("../slider/img/intro-slide-3.jpg"); opacity: 0">
  ...прочее содержимое
</section>

I
Ilya Kanyshev, 2018-02-23
@ikanyshev

How do you want to change slides?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question