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


本文摘自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 li怎么去掉点

Html字体颜色如何设置

Html中什么是标签

Html option标签怎么添加两个value?option标签的用法解析

Html tr标签怎么用

Html怎么隐藏播放器

Html实现网页标题栏添加图标

设置表格标题的Html代码是什么

Html frameset标签怎么用?Html frameset标签属性详解

Html如何设置尺寸大小

更多相关阅读请进入《Html》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...