Why should I use a container div in HTML?

前端 未结 9 1664
陌清茗
陌清茗 2020-12-23 14:33

I have noticed a common technique is to place a generic container div in the root of the body tag:


  
    ...
  
  <         


        
9条回答
  •  一整个雨季
    2020-12-23 15:12

    The most common reasons for me are so that:

    1. The layout can have a fixed width (yes, I know, I do a lot of work for designers who love fixed widths), and
    2. So the layout can be centered by applying text-align: center to the body and then margin: auto to the left and right of the container div.

提交回复
热议问题