您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

文字居中的css代码是什么

2024/4/17 22:49:28发布11次查看
文字居中的css代码是“text-align:center;”或“line-height:值;”。text-align属性规定元素文本的水平对齐方式,当值为center时,即可实现水平居中;而设置line-height可实现文字垂直居中。
本教程操作环境:windows7系统、css3&&html5版、dell g3电脑。
css 文字居中
1、文字水平居中
text-align 属性规定元素中的文本的水平对齐方式,当值为center时可实现水平居中。
<!doctype html><html> <head> <meta charset="utf-8"> <style type="text/css"> div { width: 300px; height: 200px; background: palegoldenrod; text-align: center } </style> </head> <body> <div>css 水平居中了--文本文字</div> </body></html>
效果图:
【推荐教程:css视频教程 】
2、文字垂直居中
line-height 使单行文字垂直居中
<!doctype html><html> <head> <meta charset="utf-8"> <title>css 垂直居中</title> <style> .box{ width: 300px; height: 300px; background: palegoldenrod; line-height:300px; } </style> </head> <body> <div class="box">css 垂直居中了--文本文字</div> </body></html>
效果图:
更多编程相关知识,请访问:编程视频!!
以上就是文字居中的css代码是什么的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product