NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
#### **水平垂直居中方法** #### 方法一用定位 ~~~ child{ position:absolute; top: 50%; left: 50%; margin-top: - (负)child宽度的一半(写具体值) margin-left: -( 负)高度的一半(写具体值) ~~~ #### 方法二 flex ~~~ praent{ justify-content:center; align-items:center; } ~~~ #### 方法三 定位 ~~~ child{ position:absolute; top:50%;left: 50%; transform: translate(-50%, -50%); } ~~~ #### 方法四 ~~~ child{ position:absolute; top: 0; left: 0; bottom: 0; right: 0; margin: auto; } ~~~