<style> .father{ width:200px; height:200px;; border:1px solid chartreuse; text-align: center; /*垂直居中的关键*/ display: table-cell; vertical-align: middle; } .children{ width:30%; height:50px; text-align:center; border:1px solid black; margin: 0 auto; } </style> </head> <body> <div class="father"> <div class="children"> </div> </div> </body>
垂直居中兼容性很好的方法
最新推荐文章于 2022-07-05 17:12:26 发布