In my JS image slider (Owl-Carousel), images have different dimensions:
You can see that the image height varies within the carousel. How to make it constant while keeping carousel responsive? I need images to fill the slider space at all times, therefore some will have to be cropped through CSS somehow. The desired result looks like this:
Slides with random height at http://jsfiddle.net/AwBLL/108/
HTML:
CSS:
JS:
You can achieve equal height using flexbox. Try this:
if you are using div with background image in your carsoual You can try controlling the size of the background by using the
background-size
property.Or else if you use then you can use
auto resize
according to container width}
Wish you'd put up a fiddle, but off the top of my Notepad++ you could try putting this at the bottom of your page and see if that works out for you.
if it works there are better ways to write this but it'll give you the start of a solution
It can be specified in css.
Example,
http://jsfiddle.net/AwBLL/2/
EDIT The following solution uses the plugin's callback events to modify the viewport's/wrapper's height according to the smallest image height.
http://jsfiddle.net/DNMpF/1/
js
css
EDIT2
Regarding the latest comment, to show the bottom part of the large images one approach could be to iterate the images and add a negative top margin equal to the part of these images hidden.
My images are loaded dynamically, which mean image name could changes from time to time, how could keep as a background image and pass the proper image name into css file?