How do make image automatically resize (showing full image) to fit within max-height in Twitter bootstrap carousel

I have a carousel container that must be 480px in height and 100% width.

I want the images within it to automatically resize (zoom out if necesarry) to show the whole image but never to show overflow beyond the 480px limit and never to hide part of the image..
MarkProgrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Marco GasiFreelancerCommented:
It's possible but only if you make all images the same proportions. For instance, the images I used in the example below (you can see it here: http://www.webintenerife.com/testing_script/index.php) have following dimensions

waves.gif          
          width:  750px
          height: 308px

4105054854_de562ac1fd_o-X2.jpg
          width:  1209px
          height:   496px

Bonus - Pink Sky-X3.jpg
          width:  1600px
          height:   656px

css
.carousel-inner{
    width: 100%;
    height: 480px;
}
.carousel-inner img{
    width 100%;
    hegith: 100%;
}

Open in new window


markup:
	
  	        <div class="container">
			<div class="row">
				<div class="col-12">
					<div id="myCarousel" class="carousel slide" data-ride="carousel">
						<div class="carousel-inner" role="listbox">
							<div class="item active">
								<img src="images/waves.gif" alt="First slide">
							</div>
							<div class="item">
								<img src="images/4105054854_de562ac1fd_o-X2.jpg" alt="Second slide">
							</div>
							<div class="item">
								<img src="images/Bonus - Pink Sky-X3.jpg" alt="Third slide">
							</div>
						</div>
						<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
							<span class="glyphicon glyphicon-chevron-left"></span>
							<span class="sr-only">Previous</span>
						</a>
						<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
							<span class="glyphicon glyphicon-chevron-right"></span>
							<span class="sr-only">Next</span>
						</a>
					</div><!-- /.carousel -->
				</div>
			</div>
		</div>

Open in new window

MarkProgrammerAuthor Commented:
Thanks but resizing the image at the source is not an option at the moment .. is it possible to make it center the image (vertically) in the viewport at least?
Marco GasiFreelancerCommented:
Please, let me know if all images are bigger than the carousel or if they can be smaller also.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Marco GasiFreelancerCommented:
Hi Mark. This should work:

.carousel-inner{
	width: 100%;
	height: 480px;
}
.carousel-inner > .active{
	position: relative;
	top: 50%;
	transform: translateY(-50%);				
}
	.carousel-inner>.next,
        .carousel-inner>.prev{
	top: 50%;
	transform: translateY(-50%);
}		
	.carousel-inner img{
	min-width: 100%;
}

Open in new window


Here you can see an example and the original images I used: http://www.webintenerife.com/testing_script/carousel.php

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MarkProgrammerAuthor Commented:
Sorry, have been out of office. I will try this tomorrow and reply. Thanks
MarkProgrammerAuthor Commented:
Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.