<html> <head></head> <style> * {
margin: 0px; padding: 0px } body {
display: flex; align-items: center; /*定义body的元素垂直居中*/ justify-content: center; /*定义body的里的元素水平居中*/ } body div {
display: flex; align-items: center; /*定义body的元素垂直居中*/ justify-content: center; /*定义body的里的元素水平居中*/ } </style> <body> <div style="width: 800px;height: 800px;background-color: whitesmoke;margin: auto;"> <div style="width:700px;height: 700px;background-color: honeydew;margin: auto;text-align: center;"> <div style="width:600px;height: 600px;background-color: #c0c4cd;margin: auto;text-align: center;"> <div style="width:500px;height: 500px;background-color: coral;margin: auto;text-align: center;"> <div style="width:400px;height: 400px;background-color: cadetblue;margin: auto;text-align: center;"> <div style="width:300px;height: 300px;background-color: black;margin: auto;text-align: center;"> <div style="width:200px;height: 200px;background-color: blue;margin: auto;text-align: center;"> <div style="width:100px;height: 100px;background-color: red;margin: auto;text-align: center;"> <span>红</span> </div> </div> </div> </div> </div> </div> </div> </div> </body> </html>

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/204455.html原文链接:https://javaforall.net
