Skip to content
Advertisement

Swiper Js Slider – Images overlapping in fixed height slider

Desire output: enter image description here I am trying to implement a slider with a fixed height and auto width. The images should be adjusted to e.g. height: 800px and the width should be true to the image resolution.

My Implementation: https://playground-f2831f.webflow.io/model-images/provident-at-sunt-incidunt How it is supposed to be: https://artworld.agency/artists/sarah-bassett

My slider param:

JavaScript

Advertisement

Answer

![enter image description here

1 of 2:

Set slidesPerView: "auto".

Docs demo: https://swiperjs.com/demos#slides-per-view-auto

In your case the slide width adapt the currently width of the slide content (The <img> inside). Related: boxmodel

2 of 2:

Set the image height to some value and width to auto.

JavaScript

*** The width will be proportional to the height

DEMO

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement