How can I let a div automatically set it own width?

后端 未结 4 1399
攒了一身酷
攒了一身酷 2021-02-04 10:35

How can I have a DIV\'s width behave like it does when float:left is set, but without setting a float? width:auto doesn\'t seem to do it (in chrome).

4条回答
  •  再見小時候
    2021-02-04 10:54

    I think this works nowadays:

    .center
    {
        width: fit-content;
        margin-left: auto;
        margin-right: auto;
    }
    

提交回复
热议问题