Giter VIP home page Giter VIP logo

Comments (1)

huluoyang avatar huluoyang commented on May 8, 2024

HTML时代大家用的IE盒模型,经典的如table的width属性包含了填充。
CSS时代大家用的W3C盒模型,引入了margin\padding\border属性。
CSS3.0时代大家用的box-sizing盒模型,引入了全新属性:box-sizing:border-box;
W3C经典的盒模型实际上默认的属性为:box-sizing:content-box。
但这种方式不适合布局和改版,也不符合日常生活中人们的常识。
例如:我们买了一个泡沫箱子,宽度1米,高度1米。
人们通常认为此处的宽度和高度应该等于实际可用空间+泡沫+包装。
所以现在你能看到很多网站CSS都写着:*{box-sizing:border-box},bootstrap也是如此。
这算不上误导,只是你应该抛弃掉自己陈旧的W3C盒模型知识了。
W3C本身也在不停更新迭代,但国内前端面试总是有人还在考:W3C经典盒模型和IE盒模型有什么不同?
没有任何意义,因为在连IE8都支持box-sizing:content-box的今天,我们应该果断扔掉历史包袱,轻松上阵。

from freecodecamp.cn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.