内容区域 content area
内容区域
内容区域 content area ,由内容边界限制,容纳着元素的"真实"内容,例如文本、图像,或是一个视频播放器。它的尺寸为内容宽度(或称 content-box 宽度)和内容高度(或称 content-box 高度)。它通常含有一个背景颜色(默认颜色为透明)或背景图像。
如果 box-sizing 为 content-box(默认),则内容区域的大小可明确地通过 width、min-width、max-width、height、min-height,和 max-height 控制。
设置内容是通过宽度和高度设置的:
- 宽度设置:width
- 高度设置:height
另外我们还可以设置如下属性:
- min-width:最小宽度,无论内容多少,宽度都大于或等于 min-width
- max-width:最大宽度,无论内容多少,宽度都小于或等于 max-width
- 移动端适配时,可以设置最大宽度和最小宽度;
下面两个属性不常用:(高度由内容决定)
- min-height:最小高度,无论内容多少,高度都大于或等于 min-height
- max-height:最大高度,无论内容多少,高度都小于或等于 max-height
注意
对于行内级非替换元素来说,设置宽高是无效的!
详细介绍
📄️ 元素宽度 width
width | MDN (mozilla.org)
📄️ 元素高度 height
height | MDN (mozilla.org)
📄️ 元素最小宽度 min-width
min-width | MDN (mozilla.org)
📄️ 元素最大宽度 max-width
max-width | MDN (mozilla.org)
📄️ 元素最小高度 min-height
min-height | MDN (mozilla.org)
📄️ 元素最大高度 max-height
max-height | MDN (mozilla.org)