利用CSS设置页面的垂直居中效果
生活随笔
收集整理的这篇文章主要介绍了
利用CSS设置页面的垂直居中效果
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
实现垂直居中关键的属性是text-align(文字的对其样式),line-align(垂直居中的高度),vertical-align(垂直居中)
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <style type="text/css"> #content{text-align:center; /*文字水平居中*/margin-right:auto;margin-left:auto;vertical-align:middle; /*文字垂直居中*/line-height:200px; /*垂直居中的高度*/height:200px; /*div高度*/width:400px;background:#cef; }</style> </head> <body> <div id="content"> <a>冻结了时间</a> </div> </body> </html>总结
以上是生活随笔为你收集整理的利用CSS设置页面的垂直居中效果的全部内容,希望文章能够帮你解决所遇到的问题。