Problem calculating percentage for body width

后端 未结 6 1052
無奈伤痛
無奈伤痛 2021-01-16 20:20

I need to build a classic 960px layout and I have to convert that 960px into %. So, I should use 960px / 16px = 60%, right?

Note: 960px =

6条回答
  •  北荒
    北荒 (楼主)
    2021-01-16 20:32

    The right way to calculate body width in a fluid layout:

    body {
        width:100%;
        max-width:960px;
        height:100%; 
        margin:0 auto;
    } 
    

    The max-width value should be whatever your page width is, and margin does not need a page wrap.

提交回复
热议问题