text文本设置
1.网页会有许多文字,位置居中,居左,大小如何设置?
文本颜色
color 属性用于设置文本的颜色。颜色由以下值指定:
文本对齐
text-align 属性用于设置文本的水平对齐方式。
文本可以左对齐或右对齐,或居中对齐。
color: red; 字体颜色
text-align: center; 位置居中
text-align: right; 位置居右
text-align: left;
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
div{
width: 300px;
height: 300px;
background-color: pink;
/* border: 2px solid red;*/
/* border-radius: 50px 50px 50px 50px;*/
color: red;
text-align: center;
}
</style>
<body>
<div>
helloworld!
</div>
</body>
</html>
没加之前:
加了这个:
color: red; 字体颜色
text-align: center; 位置居中
那么如何在元素的中间呢
把文字:装在子元素下,通过移动元素实现文字一起移动
文字装饰
text-decoration 属性用于设置或删除文本装饰。
text-decoration: none; 通常用于从链接上删除下划线:
text-shadow 属性为文本添加阴影
只指定水平阴影(2px)和垂直阴影(2px):
模糊程度5px
加这个:text-shadow: 2px 2px 5px red;
效果图: