本文摘自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中如何实现文本与标签居中的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
Html中怎么让表格居中
Html水平线hr颜色怎么写
Html标记中,表示网页标题的标记是什么
什么是Html h1标签?Html h1标签使用方法的详细介绍
?Html的<datalist> 标签
Html如何用超链接打开新窗口时控制其属性
怎么实现Html 可输入下拉菜单
Html css js是干什么的
Html中圆角搜索框怎么做
Html怎么实现二级选项卡
更多相关阅读请进入《Html》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » html中如何实现文本与标签居中