CSS min-width property is not functioning

后端 未结 1 1083
一生所求
一生所求 2020-12-29 20:41

I have following problem:
I have div containing other elements and I try to make its width dependent from the content. I also restrict maximum width of this div. I use <

1条回答
  •  旧巷少年郎
    2020-12-29 21:15

    By default, a block-level element will expand to fill as much width as possible. So its width is basically "100%" (sort of) and you're saying a maximum of 1000px, so it's expanding to the maximum of 1000px. The minimum width is still being achieved (it's at least 500px). Try setting display: inline-block on the element and see if that helps you out any. This should make it only expand as far as its content while still paying attention to the minimum and maximum widths. You may have to add a breaker
    after to make the rest of your content adapts to it being inline.

    0 讨论(0)
提交回复
热议问题