<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.box1 {
width: 400px;
height: 400px;
background-color: palegreen;
position: relative;
}
.box2 {
width: 100px;
height: 100px;
background-color: orange;
/* 在定位的情况下,元素水平垂直居中的方式 */
position: absolute;
margin: auto;
left: 0;
right: 0;
top: 0;
bottom: 0;
}</