首页前端开发JavaScripthtml中如何实现文本与标签居中

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

时间2024-01-29 09:32:03发布访客分类JavaScript浏览766
导读:收集整理的这篇文章主要介绍了html中如何实现文本与标签居中,觉得挺不错的,现在分享给大家,也给大家做个参考。实现方法:(推荐教程:htML教程)1、文本居中:text-align: center;line-height: 100px; (...
收集整理的这篇文章主要介绍了html中如何实现文本与标签居中,觉得挺不错的,现在分享给大家,也给大家做个参考。

实现方法:

(推荐教程: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中如何实现文本与标签居中的详细内容,更多请关注其它相关文章!

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!

html文本

若转载请注明出处: html中如何实现文本与标签居中
本文地址: https://pptw.com/jishu/590904.html
html怎么实现左右滑动导航栏 清除html页面缓存的方法

游客 回复需填写必要信息