How to scale image to fit the container?

后端 未结 7 757
我寻月下人不归
我寻月下人不归 2021-02-02 10:09

I have an image list, I want images scaled into their containers which have same size. like this:

\"a\"

7条回答
  •  野性不改
    2021-02-02 10:30

    Change the height and width to max-height and max-width. The image won't be any bigger than it's parent.

    .thumbnail img {
        max-height: 100%;
        max-width: 100%;
    }
    

    Updated Fiddle

提交回复
热议问题