当前位置:网站首页>On the value of line height
On the value of line height
2022-06-13 03:50:00 【_ Virgo programmer's daily life】
The values of row height are :
1.px, Pixel values ;
2. Numbers ;
3.em;
4. percentage
The key here is to explain that the parent element is set to ’rem’ and ’ Numbers ’ The effect of on offspring elements
<style>
.container {
/* The line height is twice the font size */
/* First calculate the pixel value , The child elements inherit */
line-height: 2em;
}
.p1{
font-size: 40px;
}
.p2{
font-size: 12px;
}
</style>
<div class="container">
<p class="p1">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Eveniet molestiae sed doloremque sapiente? Explicabo, quidem itaque, repudiandae fugiat impedit suscipit, amet inventore necessitatibus pariatur iste quisquam laborum hic aperiam ab.
</p>
<p class="p2">
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Tenetur earum corporis, eius, ut ratione nihil exercitationem cum voluptatibus et velit repellat debitis esse praesentium odio provident ex totam, delectus expedita.
</p>
</div>
The effect is as follows :
Here's why :div Of line-height yes 2em, It means the same font size 2 times .font-size Inherit browser default font-size, by 16px, be div Of line-height by 16px, Subelement p1 and p2 Of line-height Are all 32px. We can see in the browser :
p1 Of :
p2 Of :
.container {
/* The line height is twice the font size */
/* Child elements inherit first , Calculate again */
line-height: 2;
}
.p1{
font-size: 40px;
}
.p2{
font-size: 12px;
}
</style>
<div class="container">
<p class="p1">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Eveniet molestiae sed doloremque sapiente? Explicabo, quidem itaque, repudiandae fugiat impedit suscipit, amet inventore necessitatibus pariatur iste quisquam laborum hic aperiam ab.
</p>
<p class="p2">
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Tenetur earum corporis, eius, ut ratione nihil exercitationem cum voluptatibus et velit repellat debitis esse praesentium odio provident ex totam, delectus expedita.
</p>
</div>
The explanation is as follows :
div Of line-height by 2, Then its child elements inherit 2, Then each according to their font-size Calculate , be p1 Of line-heigh by 40px2=80px, be p2 Of line-heigh by 12px2=24px.
The following is displayed in the console :

notes : For the parent element itself ,line-height Are all 32px, In actual development, there will be more scenes of directly writing numbers . Because of the child element font-size It's different
边栏推荐
- LVS four - tier Load Balancing Cluster (5) LVS Overview
- leetcode.1 --- 两数之和
- Simulink code generation: table lookup module and its code
- Lambda termination operation find and match anymatch
- GoFrame第四天
- LVS four layer load balancing cluster (6) LVS working mode
- Lambda termination operation find and match nonematch
- 【MySQL】索引与事务
- 单片机:PCF8591硬件接口
- 单片机:EEPROM介绍与操作
猜你喜欢

Spark optimization - Troubleshooting

USB-IF BC1.2充电协议解读

SQL injection case demonstration and preventive measures

单片机:A/D 和 D/A 的基本概念

2022 spring semester summary

GoFrame第四天

MySQL 8.0 enables remote root user access and solves the problem of you are not allowed to create a user with Grant

单片机/嵌入式的实时性疑问解答

Window and various windowfunctions in Flink

5G China unicom AP:B SMS ASCII 转码要求
随机推荐
ROS话题与节点
Jumpserver: user - system privileged user - Asset - authorization
Lambda termination operation find and match anymatch
Lambda终结操作查找与匹配findFirst
Among the four common technologies for UAV obstacle avoidance, why does Dajiang prefer binocular vision
SQL injection case demonstration and preventive measures
Lambda end operation find and match allmatch
单片机:红外遥控通信原理
Lambda end operation reduce merge
【测试开发】文件压缩项目实战
Spark optimization - Performance (general performance, operator, shuffle, JVM) tuning
[test development] automated test selenium (II) -- common APIs for webdriver
UnionPay commerce - merchant statistics service platform
How much can I get after the insurance period of annuity insurance products expires?
[笔记]vs2015 编写汇编masm32之使用MASM32库
Lambda end operation find and match findfirst
Difference between OKR and KPI
Getting started with Oracle
Oracle built-in functions
2022 spring semester summary