How to get a div with extrinsic height and intrinsic width inside a flexbox

前端 未结 4 1348
长情又很酷
长情又很酷 2021-01-21 03:53

Problem

Say we have a vertical (i.e. flex-direction: column) flexbox container with a given width and height. The flexbox contains divs and each div contains an image.<

4条回答
  •  春和景丽
    2021-01-21 04:16

    Here's the solution for your problem.

        
    Original image

    Image in just a simple div with limited height

    You simply didn't need most of the flex properties on the img container and it's parent divs. I have used all the unused code from your HTML.

    Crucial advice: You should never use inline styling like you did here. I repeat never.

提交回复
热议问题