1. 什麼是 css 元素溢出
- visible 預設值, 顯示子标簽溢出部分。
- hidden 隐藏子标簽溢出部分。
- auto 如果子标簽溢出,則可以滾動檢視其餘的内容。
2. 示例代碼
<style>
.box1{
width: 100px;
height: 200px;
background: red;
/* 在父級上設定子元素溢出的部分如何顯示 */
/* overflow: hidden; */
overflow: auto;
}
.box2{
width: 50px;
height: 300px;
background: yellow;
}
</style>
<div class="box1">
<div class="box2">hello</div>
</div>