css文本在元素中垂直居中代码实例
分类:实例代码
分享一段代码实例,它实现了文本在元素中垂直居中的效果。
代码实例如下:
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.pipipi.net/" /> <title>犀牛前端部落</title> <style> div { width:260px; height:100px; background:#ccc; line-height:100px; } </style> </head> <body> <div>本站url地址是pipipi.net</div> </body> </html>
只要把height属性值和line-height属性值设置相同即可。
