2021.4.15

今日进度:CSS文本

  第一天  第二天 第三天  第四天  第五天 
所花时间(小时) 4.5  6  3  5  
代码量(行) 1000  200  200  300  
博客量(篇) 1  1  1  1  
了解到的知识点

python爬取热词分析

CSS边框属性  CSS框模型  CSS文本  

CSS 文本

TEXT FORMATTING

文本格式化

This text is styled with some of the text formatting properties. The heading uses the text-align, text-transform, and color properties. The paragraph is indented, aligned, and the space between characters is specified. The underline is removed from this colored "Try it Yourself" link.

该文本使用某些文本格式属性来设置样式。标题使用 text-align、text-transform 和 color 属性。段落缩进、对齐,并指定了字符间距。

文本颜色

color 属性用于设置文本的颜色。颜色由以下值指定:

  • 颜色名 - 比如 "red"
  • 十六进制值 - 比如 "#ff0000"
  • RGB 值 - 比如 "rgb(255,0,0)"

查看 CSS 颜色值,以获取可能颜色值的完整列表。

页面的默认文本颜色是在 body 选择器中定义的。

实例

body {
  color: blue;
}

h1 {
  color: green;
}

提示:对于 W3C compliant CSS:如果您定义了 color 属性,则还必须定义 background-color 属性。

文本颜色和背景色

在本例中,我们定义了 background-color 属性和 color 属性:

实例

body {
  background-color: lightgrey;
  color: blue;
}

h1 {
  background-color: black;
  color: white;
}

文本对齐

text-align 属性用于设置文本的水平对齐方式。

文本可以左对齐或右对齐,或居中对齐。

下例展示了居中对齐以及左右对齐的文本(如果文本方向是从左到右,则默认为左对齐;如果文本方向是从右到左,则默认是右对齐):

实例

h1 {
  text-align: center;
}

h2 {
  text-align: left;
}

h3 {
  text-align: right;
}

当 text-align 属性设置为 "justify" 后,将拉伸每一行,以使每一行具有相等的宽度,并且左右边距是直的(就像在杂志和报纸中):

实例

div {
  text-align: justify;
}

文本方向

direction 和 unicode-bidi 属性可用于更改元素的文本方向:

实例

p {
  direction: rtl;
  unicode-bidi: bidi-override;
}

垂直对齐

vertical-align 属性设置元素的垂直对齐方式。

本例演示如何设置文本中图像的垂直对齐方式:

实例

img.top {
  vertical-align: top;
}

img.middle {
  vertical-align: middle;
}

img.bottom {
  vertical-align: bottom;
}
原文地址:https://www.cnblogs.com/marr/p/14905252.html