盒子居总结(display:block)

xiaoxiao2021-02-28  121

<!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8" />     <title>任意盒子居中display:table</title>     <style type="text/css">         *{             margin:0;             padding:0;         }         html,body{             height:100%;         }         .element{             height:100%;             width: 100%;             background-color:blue;             text-align: center;             display:table;         }         .element .img{             display:table-cell;             vertical-align:middle;         }     </style> </head> <body> <div class="element">    <div class="img">         <img src="1.jpg" alt="" />    </div> </div> </body> </html>
转载请注明原文地址: https://www.6miu.com/read-40244.html

最新回复(0)