re:从0开始的CSS学习之路 10. 盒子模型的溢出

1. 盒子模型的溢出

父子两个盒子,子盒子的宽度或高度,大于父盒子,则子盒子多余的部分会在父盒子之外进行显示
多余的部分,称为“溢出的部分”

overflow属性,可以设置父元素如何处理溢出的内容
可选值
visible 不会处理溢出部分(默认值)
hidden 溢出的内容隐藏
scroll 为父元素添加滚动条
auto 会根据需要自动的添加滚动条

示例如下:

<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
	.father {
		width: 200px;
		height: 200px;
		background-color: #c7edcc;
	
		overflow: auto;
	}
	
	.son {
		width: 100px;
		height: 1000px;
		background-color: #fde6e0;
	}
</head>

<body>
	<div class="father">
		<div class="son"></div>
	</div>
</body>

</html>

通过修改.father overflow来查看son的显示变化

相关推荐

  1. re:0开始CSS学习 10. 盒子模型溢出

    2024-02-11 06:56:02       49 阅读
  2. re:0开始CSS学习 7. 盒子模型

    2024-02-11 06:56:02       54 阅读
  3. re:0开始CSS学习 11. 盒子垂直布局

    2024-02-11 06:56:02       60 阅读
  4. re:0开始CSS学习 4. 长度单位

    2024-02-11 06:56:02       54 阅读
  5. re:0开始CSS学习 8. 浏览器默认样式

    2024-02-11 06:56:02       51 阅读
  6. re:0开始CSS17. 定位

    2024-02-11 06:56:02       55 阅读
  7. re:0开始CSS19. 背景

    2024-02-11 06:56:02       51 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-11 06:56:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-11 06:56:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-02-11 06:56:02       82 阅读
  4. Python语言-面向对象

    2024-02-11 06:56:02       91 阅读

热门阅读

  1. 深入探索Redis:如何有效遍历海量数据集

    2024-02-11 06:56:02       56 阅读
  2. python32-Python列表和元组之通过索引使用元素

    2024-02-11 06:56:02       45 阅读
  3. python 与 图

    2024-02-11 06:56:02       43 阅读
  4. 聊聊PowerJob的InstanceStatusCheckService

    2024-02-11 06:56:02       39 阅读