本文摘自PHP中文网,作者V,侵删。
实现方法:
(推荐教程:html教程)
1、文本居中:
1 2 | text-align: center;
line-height: 100px; (=height)
|
2、标签居中
1 | margin: 0 auto; 其中0指的是margin-top:0
|
具体代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <!DOCTYPE html>
< html >
< head >
< meta charset = "UTF-8" >
< title >搜索论坛</ title >
< link rel = "stylesheet" href = "https://www.baidu.com/img/baidu_jgylogo3.gif" >
< style >
.item1{
height: 100px;
width: 100px;
background-color: red;
text-align: center;
line-height: 100px;
margin: 0 auto;
}
.item2{
height: 100px;
width: 100px;
background-color: wheat;
text-align: center;
line-height: 100px;
margin: 100px auto;
}
</ style >
</ head >
< body >
< div >
< div >1111</ div >
< div >2222</ div >
</ div >
</ body >
</ html >
|
以上就是html中如何实现文本与标签居中的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
vb输出Html乱码怎么办
怎么打开Html网页
语义化的Html结构对布局的好处是什么?
Html中src是什么意思
Html的基础 理论
Html的<sup>标签有什么用
如何使用Html布局web页面?(代码示例)
Html中关于盒模型的总结
浅谈Html里的布局对于seo的影响
Html与css有什么区别
更多相关阅读请进入《Html》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » html中如何实现文本与标签居中