Currently, I am utilizing the img
tag to display images in my slider. To achieve the desired effect of having the image fill the entire width and height while being centered within its container, I am encountering some challenges.
The issue arises when I resize the window width as the image tends to shrink without adjusting its height proportionately to match the window's height. Essentially, what I require is for the image tag to behave similarly to background-size: cover
.
background: url(../images/slider/002.jpg) center center;
background-size: cover;
Although I could resolve this by converting the image into a background element, it adversely affects the functionality of the slider. It is crucial for me to maintain the usage of the <img>
tag for this purpose.
You can view an example here.