<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            #box{
                margin: 0 auto;
                width: 150px;
                height: 150px;
                border: 1px solid #FF0000;
                position: relative;
            }

#box #text{ width: 50px; height: 50px; position: absolute; left: 0; right: 0; top: 0; bottom: 0; margin: auto; } </style> </head> <body> <div id="box"> <div id="text"> 123 </div> </div> </body> </html>
left:0; right:0; top:0; bottom:0; margin:auto;会使text居中,如果text没有宽高,则会继承父集的宽高。适合body 内的遮罩,

相关文章:

  • 2021-11-30
  • 2022-02-17
  • 2022-02-26
  • 2021-11-13
  • 2021-09-01
  • 2021-11-24
猜你喜欢
  • 2022-12-23
  • 2021-04-24
  • 2021-09-14
  • 2021-11-27
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案