Is there a way to crop images horizontally using CSS, while keeping the images visible during printing? I am currently utilizing background-image to crop images to a width of 200px without knowing the image widths in advance. My goal is to have the middle of the image displayed.
.cropped-image {
width: 200px;
height: 270px;
/* Centered, cropped image */
background-position: center;
background-repeat: no-repeat;
}
This is how my HTML template is structured:
<div class="cropped-image" style="background-image: url({{ product.image_thumb_url }})">
</div>
An example showcasing this functionality can be viewed here: http://jsfiddle.net/hRSdY/
While this method works effectively, default web browsers do not print background images. It is possible to use list-style-image
as an alternative to emulate background-image, however, cropping to the center of the image becomes challenging: http://jsfiddle.net/KP7ng/1/.