HTML中怎么使文字各种居中对齐?(代码示例)


本文摘自PHP中文网,作者藏色散人,侵删。

本篇文章主要介绍了如何去写关于html文字居中代码。希望对有需要的朋友有所帮助。

html文字居中代码具体示例如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

<!DOCTYPE HTML>

<html lang="en">

<head>

    <title>html文字居中测试</title>

    <meta charset="UTF-8">

    <style type="text/css">

        body{background: #ddd;}

        div{width:300px;height:180px;margin:10px auto;color:#fff;font-size:24px;}

        .box1{background: #71a879;text-align: center;}

        .box2{background: #6a8bbc;line-height: 200px;}

        .box3{background: #dea46b;text-align: center;line-height: 200px;}

    </style>

</head>

<body>

<div  class="box1">html文字水平居中</div>

<div  class="box2">html文字垂直居中</div>

<div  class="box3">html文字水平上下居中</div>

</body>

</html>

以上代码效果在本地测试如下图:

caf989a4270f7a1d9f2ad0f8beccefa.png

阅读剩余部分

相关阅读 >>

html中怎么使文字各种居中对齐?(代码示例)

更多相关阅读请进入《html文字居中代码》频道 >>




打赏

取消

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

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

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

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

评论

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