设置行高
- 由于简单还是老样子直接上代码了哦,注意:
line-height
属性值可以使用固定值如:20px..和百分比如:20%。 - 如果想让文字垂直居中如下:行高的主要作用是用来设置文本的垂直方向居中对齐行高的值与高度的值一样即可。
- 让我们进入
line-height
属性实践,实践内容如:将p
标签行高设置为20px。 -
代码块
<!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> p{ line-height: 20px; } </style> </head> <body> <p>成功不是打败别人,而是改变自己。</p> <p>成功不是打败别人,而是改变自己。</p> <p>成功不是打败别人,而是改变自己。</p> </body> </html>
-
结果图
-
注意:使用百分比如下简陋的代码块。
<style> p{ line-height: 20%; } </style>