Reputation: 1805
Im trying to make my slideshow to behave like this:
If the browser window is wider than or same width as my image - the image should be 100% of the window, but not heigher than 450px (cut overflow). this is pretty easy to do BUT
If the browser window is narrower than my image the image should be centered and then cut of on both left and right side. I still want a fixed height. Like this:
Is there any plugin for this? Ive tried to modify some but cant get nr 2 to work
Upvotes: 0
Views: 154
Reputation: 1199
Does your image also has fixed width ? If so you can use the solution below :
Create a container that contains your image
.container {
position:relative;
height:450px;
overflow:hidden;
}
Put your image inside the container, then add the following css
.container img {
width:600px;
position:relative;
left:50%;
margin-left:-300px; /* minus half of the width */
}
this will force the image to get centered against the container, even though the image is larger than the container.
Upvotes: 1