当前阅读教程:CSS入门到精通 > 文本居中对齐 text-align: center | |
阅读(22555525) 收藏 赞(5685) 分享 | |
上一篇: 元素居中对齐 margin: auto | 下一篇: 图片居中对齐 margin: auto |
文本居中对齐如果仅仅是为了文本在元素内居中对齐,可以使用 text-align: center; 实例代码<!doctype html> <html> <head> <meta charset="utf-8"> <title>文本居中对齐</title> <!--定义内部样式--> <style> .css1{ text-align: center;/*居中*/ border: 3px solid green;/*边框*/ } </style> </head> <body> <h2>文本居中对齐</h2> <div> 文本居中对齐。 </div> </body> </html> 效果图 |
|
上一篇: 元素居中对齐 margin: auto | 下一篇: 图片居中对齐 margin: auto |