<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
/* 横向 谁设置成auto就自动调整谁 */
.box1{
width:auto;
height: 100px;
background-color: chartreuse;
border: chocolate 20px solid;
/* 纵向 overflow 溢出 */
/* 默认值 溢出就溢出 */
/* overflow: visible; */
/* 裁剪溢出部分 */
/* overflow: hidden; */
/* 自动生成滚动条 */
/* overflow: scroll; */
/* 根据需要自动选择横向或纵向或都有的滚动条 */
overflow: auto;
}
.box2{
width: 100px;
height: 100px;
background-color: red;
/* 横向 水平居中*/
margin:auto
}
</style>
</head>
<body>
<div class="box1">
<div class="box2"></div>
</div>
</body>
</html>