本文摘自PHP中文网,作者藏色散人,侵删。
本篇文章主要介绍了如何去写关于html文字居中代码。希望对有需要的朋友有所帮助。html文字居中代码具体示例如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <!DOCTYPE HTML>
<html lang= "en" >
<head>
<title>html文字居中测试</title>
<meta charset= "UTF-8" >
<style type= "text/css" >
body{background: #ddd;}
div{width:300px;height:180px;margin:10px auto;color:#fff;font-size:24px;}
.box1{background: #71a879;text-align: center;}
.box2{background: #6a8bbc;line-height: 200px;}
.box3{background: #dea46b;text-align: center;line-height: 200px;}
</style>
</head>
<body>
<div class = "box1" >html文字水平居中</div>
<div class = "box2" >html文字垂直居中</div>
<div class = "box3" >html文字水平上下居中</div>
</body>
</html>
|
以上代码效果在本地测试如下图:

阅读剩余部分
相关阅读 >>
html中怎么使文字各种居中对齐?(代码示例)
更多相关阅读请进入《html文字居中代码》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » HTML中怎么使文字各种居中对齐?(代码示例)