I want to show only a percentage of an image (say, the top half), but in a responsive way so that resizing the viewport doesn't affect what portion of the image is shown.
The only solutions I've found rely on using a fixed height for the image (say, 200px) rather than a %age, but this isn't responsive. As you shrink the viewport, more and more of the image shows until you eventually see the entire image.
Note: My JSFiddle example is using the bootstrap class img-responsive
, which adds the following CSS properties:
display: block
max-width: 100%;
height: auto
You can also grab the middle divider/handlebar in the JSFiddle and move it around to see the effect on the image.
What can be done to meet my requirements? Is it even possible without JavaScript and with browser support down to IE9?