There is a div of a given height, the width of the div in percent. An image is inserted into the div. With a screen resolution of more than 1024, the image is centered. At a resolution equal to or less than 1024, it is cut off from one edge, since block width becomes less than image width. How can you then horizontally center the image with js and trim it from both sides?
The option to resize the image is not suitable, because height div is fixed and the image should occupy it completely.
HTML:
<div class="box"> <img src="http://hashcode.ru/upfiles/logo.png"> </div> <div class="box"> <img src="http://hashcode.ru/upfiles/logo.png"> </div> <div class="box"> <img src="http://hashcode.ru/upfiles/logo.png"> </div> <div class="box"> <img src="http://hashcode.ru/upfiles/logo.png"> </div> CSS:
.box { width: 21%; height: 70px; background: #222; float: left; text-align: center; margin: 20px 2%; overflow: hidden; }