问题计算主体宽度的百分比 [英] Problem calculating percentage for body width

查看:119
本文介绍了问题计算主体宽度的百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要构建一个经典的960px布局,我必须将960px转换为%。
那么,我应该使用 960px / 16px = 60%,对吗?

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


注意:960px =正文宽度

16px =字体大小

Note: 960px = body width
16px = font size

strong>:

The problem:

body {width:60%;} /* 960 / 16px */

小于

body {width:960px;}



<

at same screen dimensions/resolution/width.

我知道只是调整到74%看起来更好,但是我必须重新计算所有的布局(边距,paddings,宽度)以适应74%。

I know that just resizing it to 74% looks better but then I have to re-calculate all my layout (margins, paddings, widths) to fit that 74%.

我已经阅读了很多流畅/敏感的文章,我找不到一种方法来计算适当的身体大小。

I have read a lot fluid/responsive/elastic articles and I cannot find out a way to calculate a proper body size.

推荐答案

以流畅的布局计算体宽的正确方法:

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

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

max-width 值应该是您的页面宽度, margin 不需要换页。

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

这篇关于问题计算主体宽度的百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆