S
S
Sergey Khlopov2021-01-26 21:23:46
css
Sergey Khlopov, 2021-01-26 21:23:46

How to improve CLS using Owl Carousel sliders?

Hello, please tell me, there are several sliders with products on the page, when the page is loaded, when the pictures are loaded, the sliders do not have a height:
60105c39a9645225844984.png
Then, when the pictures are loaded, it looks like this:
60105c8821201115261417.png
Accordingly, the layout jumps, and because of this, CLS is bad in Google PageSpeed. Please tell me how to do it so that the layout does not jump, if I set min-height or height, then on small screens the height of the slider is more than necessary.
Thank you in advance for your response.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2021-01-27
@Shlop

Try to make the image block padding-bottom: 100%;
Make the image either a picture as an absolute, or through background-image
PS
I do this on my projects. The slider class is the element's parent

.slider {
   display: flex;
   position: relative;
   opacity: 0;
   transition: opacity 1s ease;
}

.owl-loaded {
   opacity: 1;
   display: block;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question