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

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

    An working demo is here-

    .floating-box {
        display:-moz-inline-stack;
        display: inline-block;
    
        width: fit-content; 
        height: fit-content;
    
        width: 150px;
        height: 75px;
        margin: 10px;
        border: 3px solid #73AD21;  
    }

    The Way is using inline-block

    Supporting elements are also added in CSS.
    Floating box
    Floating box
    Floating box
    Floating box
    Floating box
    Floating box
    Floating box
    Floating box

提交回复
热议问题