html中如何實作文字與標籤居中

王林
發布: 2020-08-29 16:30:17
轉載
5616 人瀏覽過

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中如何實作文字與標籤居中的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:csdn.net
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!