Reputation: 107
I wont my image to be responsive like the rest of my website will be. How do i make it adjust to the size of the container. Not just the width but also resize the height?
The image is in a container with a max-width of 1300px, so i have made a test image that has the sizes 400px height and 1300px width
Here is the jsfiddle so you can have a look at what i mean.
http://jsfiddle.net/z6fj8dtg/2/
<div id="wrapper">
<div id="codeback">
</div>
<div id="container">
<div class="nav">
</div>
<div id="wrap">
<div class="banner">
<img src="http://s12.postimg.org/vnsghsvf1/banner.png" >
</div><!-- END OF BANNER -->
</div>
</div><!-- END OF CONTAINER -->
body{
background-color:#272822;
padding:0;
margin:0;
}
#wrapper{
width:100%;
height:inherit;
}
#codeback{
width:100%;
height:100%;
background-image:url('capture.jpg');
background-repeat: no-repeat;
position:fixed;
left:0px;
top:0px;
z-index:-1;
}
#container{
width:100%;
float:right;
}
.nav{
margin-top:200px;
width:80%;
max-width:1300px;
height:50px;
float:right;
background-color:black;
position:relative;
}
.fixedNav {
position:fixed;
margin:0;
width:80%;
right:0;
}
#wrap{
float:right;
width:80%;
max-width:1300px;
height:1500px;
background-color:white;
box-shadow: -1px -1px 35px lightblue;
}
.banner{
max-width:100%;
}
At the minute it just sits in the container but overflows to the right.
Upvotes: 3
Views: 14828
Reputation: 415
i used bootstrap image responsive class img-fluid and extra div tags to control image size.
<div style="width: 20%;height: 100px">
<img src="http://www.everlastingcelebrations.com/wp-content/uploads/2018/09/Top-Ganesh-Chaturthi-Messages-Images-Photos.jpg" class="img-fluid" alt="...">
</div>
Upvotes: 0
Reputation: 5294
Yes that's no problem at all. Just insert the following CSS:
.banner img {
width: 100%;
height: auto; //Auto adjust height (maintain aspect ratio)
}
Upvotes: 11