Making a div the same size as an image inside it

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

I have an div with the following code

HTML:

7条回答
  •  轮回少年
    2021-02-13 12:34

    This will do the work:

    div{
        border:1px solid black;  /* you can remove this */
        box-sizing:border-box; /* you can remove this */
        padding:13px;
        min-width:250px;
        min-height:250px;
        display:inline-block;
    }
    

    So either use float on your div or just use display:inline-block manually.

    Here is example: http://jsfiddle.net/mxykW/

提交回复
热议问题