为什么W3C框模型被认为更好? [英] Why is the W3C box model considered better?

查看:117
本文介绍了为什么W3C框模型被认为更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么大多数开发人员认为W3C框模型比Internet Explorer使用的框模型更好?

Why do most developers consider the W3C box-model to be better than the box-model used by Internet Explorer?

这是非常令人沮丧的开发的网页,看起来你想要的方式在Internet Explorer上,但我发现W3C箱模型反直觉。例如,如果边距,填充和边框被计入宽度,我可以为所有列分配宽度值,而不必担心列数,以及对其填充和边距所做的任何更改。

It's very frustrating developing pages that look the way you want them on Internet Explorer, but I find the W3C box-model counter-intuitive. For example, if margins, padding, and border were factored into the width, I could assign width values to all my columns without worrying about the number of columns, and any changes I make to their padding and margins.

使用W3C的盒子模型,我不得不担心列的数量,并开发类似于数学公式的东西,以便在修改边距和填充时计算正确的宽度值。改变它们的值将是困难的,特别是对于复杂的布局。考虑这个我写的小框架:

With W3C's box-model I have to worry about the number of columns I have, and develop something akin to a mathematical formula to calculate the correct width values whe modifying margins and padding. Changing their values would be difficult especially for complex layouts. Consider this small frame-work I wrote:

#content {
margin:0 auto 30px auto;
padding:0 30px 30px 30px;
width:900px;
}
    #content .column {
        float:left;
        margin:0 20px 20px 20px;
    }
    #content .first {
        margin-left:0;
    }
    #content .last {
        margin-right:0;
    }   
        .width_1-4 {                    
            width:195px;                
        }                       
        .width_1-3 {
            width:273px;                
        }
        .width_1-2 {
            width:430px;
        }
        .width_3-4 {
            width:645px;
        }
        .width_1-1 {
                    width:900px;
        }

我在这里分配的值会变得不稳定,除非有三列,在 0 + 20 + 20 + 20 + 20 + 0 。很难修改填充和边距;我的整个宽度将不得不重新计算。如果列宽加入填充和边距,我所需要做的是改变宽度,我有我的布局。我不太批评盒子模型,更希望了解为什么它被认为更好,因为我发现很难使用。

The values I assigned here will falter unless there are three columns, and thus margins at 0+20+20+20+20+0. It would be difficult to modify padding and margins; my entire widths would have to be recalculated. If column width incorporated padding and margins, all I would need to do is change the width and I have my layout. I'm less criticizing the box-model and more hoping to understand why it's considered better as I'm finding it difficult to work with.

我做错了?使用W3C的盒子模型似乎很直观。

Am I doing this thing wrong? It just seems counter intuitive to use W3C's box-model. Some advice would be really appreciated.

感谢!

推荐答案

字回答 - -box-sizing

您可以选择自己想要的盒子模型

这篇关于为什么W3C框模型被认为更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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