0

First time caller, long time listener.

I'm trying to fit my pictures into this slick carousel but the vertical portion is always going outside of the boundary. Ideally, I want my pictures to fill the carousel section (cover) and want the size to adapt responsively to screen size changes.

I'm new to coding and have tried a lot. Here are some links to the site where I am right now:

https://codepen.io/jerimijones/pen/WXvBMX

#carousel {
  width: 70%;
  height: 90%;
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -20%);
  border-color: white;
  border-style: solid;}

https://carouseltest.netlify.com/

Any help would be greatly appreciated.

Richard Dallaway
  • 4,250
  • 1
  • 28
  • 39

1 Answers1

0

A possible duplicate of CSS Image size, how to fill, not stretch?


You can use the css property object-fit.

.cover {
  object-fit: cover;
  width: 50px;
  height: 100px;
}

See example here

There's a polyfill for IE: https://github.com/anselmh/object-fit

phocks
  • 2,933
  • 5
  • 27
  • 28