100% DIV width is not really 100%

后端 未结 8 1585
太阳男子
太阳男子 2020-12-01 18:09

When I have a

with width: 100%, it is not really 100%:

testtesttesttesttest
... #di
相关标签:
8条回答
  • 2020-12-01 18:45

    This oughta do it (add this line to the very top of your CSS file):

    * { margin: 0; padding: 0; }
    

    Works all the time for me.

    0 讨论(0)
  • 2020-12-01 18:49

    100% is only 100% of the available width, based on the parent container. So if you create a DIV with width 500 pixels, then nest another DIV inside with width 100%, your 100% DIV can expand to a maximum of 500 pixels (not counting any padding or margin so you need to reset them to 0).

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