Introduction
- In
CSS
thetext-align
attributes there are three types of values, as follows:left
left,center
middle,right
and right. - I will not repeat because of the simple introduction of direct access to the
text-align
property 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>