如何将HTML页面中的文本设置首行缩进

text-indent属性介绍

属性值单位 描述
em 比如:1em 就代表缩进1个字,2em缩进2个字.....。
  • 由于简单我就不过多的介绍了直接上代码了哦,注意:text-indent属性的值支持为负数具体园友可以尝试下。
  • 代码块

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>设置首行缩进</title>
    <style>
        p{
            text-indent: 2em;
        }
    </style>
</head>
<body>
    <p>成功不是打败别人,而是改变自己。
        成功不是打败别人,而是改变自己。成功不是打败别人,而是改变自己。
        成功不是打败别人,而是改变自己。成功不是打败别人,而是改变自己。
        成功不是打败别人,而是改变自己。成功不是打败别人,而是改变自己。
        成功不是打败别人,而是改变自己。成功不是打败别人,而是改变自己。
        成功不是打败别人,而是改变自己。成功不是打败别人,而是改变自己。
        成功不是打败别人,而是改变自己。成功不是打败别人,而是改变自己。
    </p>
</body>
</html>
  • 结果图

猜你喜欢

转载自www.cnblogs.com/lq0001/p/11878770.html