How do I set this div to be the minimum possible width to display its floating contents?

后端 未结 4 1389
我在风中等你
我在风中等你 2020-12-31 05:13

Problem

I have \"boxes\" that float left so that I can display them in a line until they need to wrap. This works well, but my coloured background doesn\'t shrink

4条回答
  •  -上瘾入骨i
    2020-12-31 05:58

    Remove the min-width from the .container and add display:inline-block;

    also if you want to center the .container then wrap the .container with a div and apply text-align:center to it.

    .container {
        background: #fcc;
        margin: 0 auto;
       display:inline-block;
    }
    

    jsFiddle Link

提交回复
热议问题