How to make a parent div auto size to the width of its children divs

前端 未结 2 1360
失恋的感觉
失恋的感觉 2021-02-01 11:47

I\'m trying to make the parent div only as wide as the child div\'s. Auto width is making the parent div fit the entire screen. The children divs will be different widths depend

2条回答
  •  不思量自难忘°
    2021-02-01 12:14

    The parent div (I assume the outermost div) is display: block and will fill up all available area of its container (in this case, the body) that it can. Use a different display type -- inline-block is probably what you are going for:

    http://jsfiddle.net/a78xy/

提交回复
热议问题