<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>05盒子居中写法</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
.box1 {
width: 500px;
height: 500px;
background: blue;
display: flex;
align-items: center;
justify-content: center;
}
.box1_1 {
width: 200px;
height: 200px;
background: green;
}
</style>
</head>
<body>
<!--
实现一个宽高为200*200的小盒子在一个宽高为500*500的大盒子里面做水平垂直居中效果。
-->
<!-- 7.给大盒子添加弹性盒,让其中的flex项目水平垂直对齐 -->
<div class="box1">
<div class="box1_1"></div>
</div>
</body>
</html>```
弹性盒模型使盒子内的内容垂直水平居中
最新推荐文章于 2024-06-02 17:14:20 发布