I have a bootstrap 2.3.2's carousel on homepage. It's dimesions are 870px × 320px. The images to be shown on the carousel have generally thinner like 620px × 350px; I want to stretch images to full-width (870px) while preserving current width/height ratio.
This can be done using
.carousel { height:320px; width:870px; }
.carousel .item { width:100%; max-width:100%; height:320px;}
.carousel img { width:100%; height:auto; overflow:hidden; }
I want to overlap image's center point with carousel's center. Incoming image will be higher than carousel's height after stretching to 100% witdh. I want it to overflow top and bottom equally.
For example if I stretcg a 620px × 350px image to 870px width the new height value will be 490px approx. Substracting it from 320px overflowing height is 170px. So I want it to overflow 85px from top and 85px from bottom.
Image 1 is what I have and Image 2 is what I desire.
What I have tried is to add margin-top with negative value which is not recommended. Also I have no chance to make calculation in CSS. It should be shift up a bit only.