深入了解CSS中盒子模型
原文: 深入了解CSS中盒子模型 CSS中盒子模型介绍 # 什么是盒子? 盒子是用来存储物品,我们可以将盒子理解为酒盒,酒盒有什么组成的呢? 有酒可以喝、有填充物保护酒防止酒被摔坏、纸盒子。 我们怎么理解 CSS 中的盒子呢, CSS 中盒子有什么组成的呢?有内容、内边距、边框、外边距。 CSS 中盒子的主要属性有 5 种如: width 宽度、 height 高度、 padding 内边距、 border 边框、 margin 外边距。 CSS中盒子模型实践 # CSS 中盒子模型实践,给大家看看我们 CSS 中的盒子长什么样。 代码块 Copy<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>盒子模型</title> <style> div { /*这里的宽度指的就是盒子内容的宽度*/ width: 100px; /*这里的高度值的就是盒子内容的高度*/ height: 100px; /*内边距就是盒子里面的内容到边框的距离*/ padding