CSS文本属性与字体

一,文本属性

  • text-decoration

  • text-transform

  • text-indent

  • text-align

  • word/letter-spacing

text-decoration

++text-decoration++取值为:

  • none:去除所有装饰
  • underline:添加下划线
  • overline:添加上划线
  • line-through:添加中划线

text-transform

++text-transform++取值为:

  • capitalize:把每个单词的首字符变为大写
  • uppercase:把每个单词的所有字符变为大写
  • lowercase:把每个单词的所有字符变为小写
  • none:无影响

text-indent

++text-indent++ 为第一行的缩进大小。

html 复制代码
text-indent:2em;

text-align

++text-align++取值为:

  • left:左对齐
  • right:右对齐
  • center:居中对齐
  • justify:两端对齐

!text-align只适用于行内元素

text-align:center与text-align:justify的区别:

html 复制代码
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  div {
    height: 200px;
    width: 30%;
    background-color: azure;
    text-align: center;
  }
</style>

<body>
  <div>Welcome to Flask's documentation.
    Get started with Installation and then get an overview with the Quickstart.
    There is also a more detailed Tutorial that shows how to create a small but complete application with Flask.
    Common patterns are described in the Patterns for Flask section.
    The rest of the docs describe each component of Flask in detail, with a
    full reference in the API section.</div>

</body>

</html>
html 复制代码
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  div {
    height: 200px;
    width: 30%;
    background-color: azure;
    text-align: justify;
  }
</style>

<body>
  <div>Welcome to Flask's documentation.
    Get started with Installation and then get an overview with the Quickstart.
    There is also a more detailed Tutorial that shows how to create a small but complete application with Flask.
    Common patterns are described in the Patterns for Flask section.
    The rest of the docs describe each component of Flask in detail, with a
    full reference in the API section.</div>

</body>

</html>

letter-spacing

letter-spacing可以控制字间距,可以为负数。

二,字体属性

  • font-size
  • font-family
  • font-weight
  • line-height
  • font-style
  • font-variant

font-size

++数值+单位++

html 复制代码
font-size:10px;
font-size:2em;

++百分比(相对于父级元素的大小++)

html 复制代码
font-size:50%;

font-family

字体类型设置

font-weight

++字体大小设置++

取值:

100/200/300.....,每个数字表示一个重量

normal = 400

bold = 700

line-height

行高为基线之间的距离:

font-style

++font-style++取值:

  • normal:常规显示
  • italic:斜体形式
  • oblique:倾斜

font-variant

normal:常规显示

small-caps:将小写字母替换为缩小过的大写字母

相关推荐
写不来代码的草莓熊1 小时前
vue前端面试题——记录一次面试当中遇到的题(5)
前端
weixin_ab1 小时前
【HTML分离术】
前端·html
文心快码BaiduComate1 小时前
新手该如何选择AI编程工具?文心快码Comate全方位体验
前端·后端·程序员
夫唯不争,故无尤也1 小时前
Tomcat 内嵌启动时找不到 Web 应用的路径
java·前端·tomcat
lichong9511 小时前
【Xcode】Macos p12 证书过期时间查看
前端·ide·macos·证书·xcode·大前端·大前端++
oh,huoyuyan1 小时前
如何在火语言中指定启动 Chrome 特定用户配置文件
前端·javascript·chrome
前端大聪明20022 小时前
single-spa原理解析
前端·javascript
一枚前端小能手2 小时前
📦 从npm到yarn到pnpm的演进之路 - 包管理器实现原理深度解析
前端·javascript·npm
影i2 小时前
CSS Transform 和父元素撑开问题
前端
@大迁世界2 小时前
Promise.all 与 Promise.allSettled:一次取数的小差别,救了我的接口
开发语言·前端·javascript·ecmascript