css+div絕對居中
阿新 • • 發佈:2019-01-28
<!DOCTYPE html> <html> <head> <title>居中</title> <meta charset="utf-8"/> <!-- css 程式碼 --> <style type="text/css"> .container { background: rgba(0,0,0,.3); width: 400px; height: 260px; position: absolute; left: 50%; top: 50%; margin-left: -200px; margin-top: -130px; color: #fff; text-align:center; } </style> </head> <body> <div class="container">.container區塊 始終顯示在頁面的中心</div> </body> </html>