Centering div with unknown width

前端 未结 4 630
后悔当初
后悔当初 2020-12-14 15:48

i have div

which contains all page content including header footer etc.

So i would like to center this div to t

4条回答
  •  眼角桃花
    2020-12-14 16:07

    This will give you a dinamically-sized div that stays at the center of the body and is the smallest size needed to fit the content:

    body { text-align: center; }
    div.container { display: inline-block; text-align: left; }
    

提交回复
热议问题