水平垂直居中

xiaoxiao2021-02-28  71

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport"content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible"content="ie=edge"> <title>div水平垂直居中</title> <style> .center { background-color: #f00; width: 50%; height: 50%; position: fixed; top: 50%; left: 50%; -webkit-transform: translateX(-50%)translateY(-50%);     } </style> </head> <body> <div class="center"></div> </body> </html> 第三中方法是比较成熟的不是固定高宽div的垂直居中的方法!但是方法是css3的写法,想兼容IE8的童鞋们,建议用其他方法。

转载请注明原文地址: https://www.6miu.com/read-79835.html

最新回复(0)