div内容水平垂直居中的正确玩法
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <style> .container { text-align: center; height: 300px; border: 1px solid rebeccapurple; } .container:before { display: inline-block; vertical-align: middle; content: ""; height: 100%; } .center { display: inline-block; vertical-align: middle; } </style> </head> <body> <div class="container"> <div class="center"> <h1>这个是居中标题</h1> <p>这里是一些文字,文字</p> </div> </div> </body> </html>
改自:http://www.mamicode.com/info-detail-1275208.html
相关推荐
HSdiana 2020-03-28
FZfeng 2018-04-04
Ivy 2016-08-14
drdrsky 2020-06-16
葉無聞 2020-03-23
lyg0 2020-03-07
冰蝶 2020-01-10
玫瑰小妖 2019-12-31
行吟阁 2019-12-08
aiolos 2016-04-15
loverlucky 2016-03-15
WebVincent 2019-07-01
云端漂移 2019-07-01
renpinghao 2019-06-30