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

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

I have a layout similar to:

I would like for the div to only exp

30条回答
  •  花落未央
    2020-11-21 07:59

    There are two better solutions

    1. display: inline-block;

      OR

    2. display: table;

    Out of these two display:table; is better, because display: inline-block; adds an extra margin.

    For display:inline-block; you can use the negative margin method to fix the extra space

提交回复
热议问题