Open utterances-bot opened 2 years ago
以下方案均基于如下布局和基础样式:
https://febook.hzfe.org/awesome-interview/book4/css-vertical-horizontal-center
建议使用类选择器
flex还有个简单的
display: flex; width: 100px; height: 100px; background: red; }
margin: auto; width: 50px; height: 20px; background: blue; }
Grid
#parent { display: grid; place-items: center; }
水平垂直居中方案 | HZFE - 剑指前端 Offer
以下方案均基于如下布局和基础样式:
https://febook.hzfe.org/awesome-interview/book4/css-vertical-horizontal-center