首页 > 网站 > WEB开发 > 正文

块级元素-盒子模型

2024-04-27 14:27:57
字体:
来源:转载
供稿:网友
块级元素-盒子模型

前言

  第一周即将结束,《CSS权威指南》已近尾声,真心推荐,是本好书,会带来一些新的认识,比如说盒子模型。

  如果想讨论讨论,欢迎评论,共同进步嘛,初来乍到,有何不妥,请多多指点。

引入问题

  据说CSS中最基础的一个重点,也就是最重点的一个基础,就是盒子模型,究竟什么是盒子模型?

基本概念

  本文中会提到的名词列在下面,如文章有其他不熟悉的词汇,请请求网络帮助。

    1.正常流:正常文本从左向右、从上向下显示,称为正常流,本文一律在正常流下进行讨论,浮动和定位会让元素脱离正常流。

    2.非替换元素:元素内容包含在文档中,如<p>、<h1>。

    3. 替换元素:用作为其他内容占位符的元素,如<img>。

    4. 块级元素:本文介绍块级元素的一些特征,从最基本的<div>、<p>元素开始。

    5. 外边距(margin):默认值为0,可以为负数。

    6. 边框(border):默认没有边框,宽度不能为负数。

    7. 内边距(padding):默认值为0,不能为负数。

    8. 宽度(width):默认值为auto,不能为负数,为内容宽度(不包括内边距)。

    9. 高度(height):默认值为auto,不能为负数,为内容高度(不包括内边距)。

盒子模型

  开篇第一图盗自百度百科。      

  这就是伟大的盒子模型,有什么特性,你猜。为了方便下文的观察,CSS噼里啪啦敲些东西。    PRBbNJnd3nD8ew4MAtGf+DTg/2Beu5+6Ftu3Q8j38v+7Y0m9F+C50+P96dDqvRESDx/eryfPYLyL/9ctKj9MD64Nxr2yTHByFOLMVIfRzql4wez47F6lmRqn93rDcezaKxdXDOX+phy1YgHjww2NFh1NulbGgAAADwa1uC5ZiLq9Tx5O5E0uXNPt1Cyvf3weD8c+uHQ6vsQQukHvJbrQtLtjaJUSPoh2TuYyIX0mDII4aeEfnJNul0RKqFGGtkAIlapfmiU2N4oUkYJSXnyRVG7rGw9bzguqZHkgn6QNxICAICHTRFxpdKSMZgwHXcxkn7WoB+z4/1Y9qTIJ1E12ftJFc4bju1dtqyFvVHEdfG8uKZKQ8VV0/vj/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ZUXvxpvR22Y/psNhuSPUAbc1eJBiVjZTMtp8xHXJK4Nt3YAwFOEFdem1yRosV8am41Tb8ydXXnPVdVj3duT8n3UK8hLJLnAdXx9vlT5nqINxb9XvuFg9bcYcU0yeG15apzl5Yg3FVfGGdXSbtVBgLq6ST5y1WFhrMABALiHE9cVrklI1yDqvwogCWGOt1ouD9Y9VrWorBOGlB+6xMXq3sniKvnr1J6TPk0GVj9JIY6UKyiVQG2wIidXq3dZTxvLoT0lAQA8InRxXc2aBBczka2hibiifT1SIc32g3gm2BKyjl12VqT1T2Tkwf4STm769zrBChwAQCOs5fdcHxfK954AAAA8eSCu1clxCgEAADxVIK4AAACAYyCuAAAAgGMgrgAAAIBjIK4AAACAYyCuAAAAgGMYcZ1tvrvbfDNr5H4vLjff3SVcdpxd2WmZX1xuvlt0fnb77LPL2+Xydrn8dr7r1qRHe4ubg8XN3mHekTtn4eImPN0pcM2d7aubg/mRWws0x4xrUbud6G4zOnfQxupbo3AdPeRaeOB1ZL3y1dmzdRuwFiXefSNb85uDxcWW8YC4kR9Uaeo2np1eHyyut3caMMvuh+/L2+Xydrn4sNuA2auJ68/nm+/uNl9WL1DnzZMS19nl7XL5RzPjFdGmCzS+wwv1sMML/jVw8Soaef7p48n9l5P799v63tn7k/svMT+Onhfb23kjqn63E2VtoPNy4aqBObBG4Toqe19TDaKOnHG0t3j4Qxz93S9PnrjSez0QcY15e7m8XV6+dX5liKuOc3F9e7m8/X4euK25sjw7vVbeDX1LTENdtuh5f/v0+tUPruOevT+5/xLNxL+vI6XvNu6dbb6723zR6YrOWrhBon2+cFPspqzh4L7GGkQduaLRgeaqcNJOH

上一篇:[note]CSS&amp;lt;二&amp;gt;

下一篇:初入博客

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表