Trimming the inner content of a div

I have a 147x88 DIV and inside it is an image with the same width, but may be larger in height. In this case, the image goes beyond the div. In any case, in order to freeze the image, remember that I want my page to work in older browsers that do not support CSS3 (IE7 and IE8)?

+6
source share
4 answers

Just hide the div overflow and the containing image is cropped to the size of the div.

div{width: 147px; height: 88px; overflow: hidden;} 
+8
source

div { width: 147px; height: 88px; overflow: hidden; }

+3
source

Install overflow:hidden; in the div:

 #yourDiv { width:147px; height:88px; overflow:hidden; } 

Example: http://jsfiddle.net/purmou/sN5PL/

+3
source

This question shows how to get image size using jQuery. You may have a small block that checks the size of the image when loading the page and accordingly sets the size of the DIV.

+1
source

Source: https://habr.com/ru/post/895129/


All Articles