本文摘自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 applet标签是什么意思?Html applet标签的用法详解
Html的<keygen> 标签
什么是Html元素?浅谈元素的语法规则
Html mark标签怎么用
Html实现实时效果查看功能
Html head标签怎么用
Html怎么自动关闭页面
npm机制深入理解
js开发之动态修改网页元素样式
怎么修改Html文件
更多相关阅读请进入《Html》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » html中如何实现文本与标签居中