CSS Sets the horizontal alignment direction of the text

Introduction

  • In CSSthe text-alignattributes there are three types of values, as follows: leftleft, centermiddle, rightand right.
  • I will not repeat because of the simple introduction of direct access to the text-alignproperty practice, and if you are a novice he must go to practice Ha, the results chart is not on display, and we move their hands and Kazakhstan.
  • Left block

<!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>
        .box{
            text-align: left;
        }
    </style>
</head>
<body>
    <h2 class="box">成功不是击败别人,而是改变自己</h2>
</body>
</html>
  • Note: The default is left-aligned.

  • In block

<!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>
        .box{
            text-align:center;
           
        }
    </style>
</head>
<body>
    <h2 class="box">成功不是击败别人,而是改变自己</h2>
</body>
</html>
  • Right block

<!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>
        .box{
            text-align: right;
        }
    </style>
</head>
<body>
    <h2 class="box">成功不是击败别人,而是改变自己</h2>
</body>
</html>

Guess you like

Origin www.cnblogs.com/lq0001/p/11863676.html
Recommended