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

后端 未结 4 1398
攒了一身酷
攒了一身酷 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:51

    For those of you who are still coming across this issue, nowadays you can handle this with:

    This will expand only as far as it needs to

    Here is a new fiddle based on the accepted answer: http://jsfiddle.net/j33qL8pa/1/

提交回复
热议问题