html中如何实现文本与标签居中

互联网 20-8-29

实现方法:

(推荐教程:html教程)

1、文本居中:

text-align: center; line-height: 100px; (=height)

2、标签居中

margin: 0 auto;   其中0指的是margin-top:0

具体代码:

<!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中如何实现文本与标签居中的详细内容,更多内容请关注技术你好其它相关文章!

来源链接:
免责声明:
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场
标签: 标签
上一篇:php获取远程图片并下载保存到本地的方法分析 下一篇:清除html页面缓存的方法

相关资讯