1. 程式人生 > >css實現彈出視窗始終垂直水平居中

css實現彈出視窗始終垂直水平居中

<!DOCTYPE html><html> <head> <meta charset=" utf-8"> <title>螞蟻部落</title> <style type="text/css"> body{ height:1000px; } .antzoen{ position:fixed; width:250px; height:100px; background:#ececec; left:50%; top:50%; margin-left:-125px; margin-top:-50px
} </style> </head> <body> <div class="antzoen"></div> </body> </html> 但是這種方法ie6不支援fixed屬性,但是現在大多不再考慮ie6。所以儘可以放心使用。