Making a div the same size as an image inside it

前端 未结 7 2281
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-13 12:21

I have an div with the following code

HTML:

7条回答
  •  情书的邮戳
    2021-02-13 12:38

    Does floating the div work with your layout? This will cause its width to wrap to the contained image.

    div#imgContainer {
        min-width: 250px;
        min-height: 250px;
        padding: 13px;
        float: left;
    }
    

    If you need to clear it, add a wrapping element with overflow: hidden.

提交回复
热议问题