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

前端 未结 30 3756
青春惊慌失措
青春惊慌失措 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:55

    We can use any of the two ways on the div element:

    display: table;
    

    or,

    display: inline-block; 
    

    I prefer to use display: table;, because it handles, all extra spaces on its own. While display: inline-block needs some extra space fixing.

提交回复
热议问题