How can I make a div not larger than its contents?

前端 未结 30 3623
青春惊慌失措
青春惊慌失措 2020-11-21 07:35

I have a layout similar to:

I would like for the div to only exp

30条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-21 08:02

    This has been mentioned in comments and is hard to find in one of the answers so:

    If you are using display: flex for whatever reason, you can instead use:

    div {
        display: inline-flex;
    }
    

    This is also widely supported across browsers.

提交回复
热议问题