Do you want to know how to control the image height while scaling it to full width?
One approach is to set a fixed maximum height using max-height
. For example, you could use height: 200px
, but this might cause distortion if the image stretches horizontally.
Another option is to use a div
tag with a background image instead of an img
tag. This provides more flexibility in adjusting the size of the image:
<div style="
background-image: url(images/slide1).jpg;
background-position: 50% 50%;
background-repeat: no-repeat;
background-size: cover;
height: 200px;
width: 100%;
"></div>
With this method, the block containing the image will maintain a height of 200 pixels and preserve the aspect ratio by cutting off any parts of the image that extend beyond the block.