• 技术文章 >web前端 >html教程

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

    VV2020-08-29 16:30:17转载1971

    实现方法:

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

    声明:本文转载于:csdn,如有侵犯,请联系admin@php.cn删除
    专题推荐:html 文本 标签
    上一篇:清除html页面缓存的方法 下一篇:什么是对html的补充,可以使网页形式和内容分离?
    大前端线上培训班

    相关文章推荐

    • 如何用CSS将select/option文本居中或居右对齐_html/css_WEB-ITnose• 页面文本居中问题_html/css_WEB-ITnose• css中怎么设置文本居中?css文本垂直居中的设置方法• html和url有什么区别么

    全部评论我要评论

  • 取消发布评论发送
  • 1/1

    PHP中文网