CSS: I can't set width to “auto” always appear 100%

后端 未结 7 926
太阳男子
太阳男子 2021-01-28 16:56

for some reason

the width of the div is 100% and if i set it to auto, nothing changes. tried display: block; and still nothing.

what I have in

7条回答
  •  無奈伤痛
    2021-01-28 17:18

    width:auto on a DIV expands it to fill it's parent, not to be sized by it's children.

    ex: http://jsfiddle.net/nTWvr/

    To size a DIV by it's content, there are a few methods: How to make div not larger than its contents?

提交回复
热议问题