resize image using css

前端 未结 3 851
南旧
南旧 2021-01-25 16:53

I am trying to resize image using css only.

It is resizing but for some reason it is not stretching to 100% of the browser.What I want is it will resize the image with g

3条回答
  •  忘掉有多难
    2021-01-25 17:51

    The following code resizes the image proportionally to the width of the page (or more correctly, the container element), but if the height of the image then becomes more than 485px then the width with will be proportional to that. To chop the image, put another div around it with the right width and height, and set overflow to hidden, and remove the max-height from the image itself.

    .resize_image img {
        display: block;
        height: auto;
        max-height: 485px;
        max-width: 1440px;
        width: 100%;
    }
    

    Hope this helps.

提交回复
热议问题