当前位置:网站首页>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
边栏推荐
- [multithreading] what is multithreading in the end -- the elementary level of multithreading (review for self use)
- Oracle built-in functions
- Jumpserver installation
- Fundamentals of robot obstacle avoidance system
- Use of file class
- OKR和KPI的区别
- LVS 4 - tier Load Balancing Cluster (3) Cluster Function Classification - HPC
- try-catch finally执行顺序的例题
- 单片机:A/D 差分输入信号
- 单片机:EEPROM介绍与操作
猜你喜欢
随机推荐
Lambda终结操作查找与匹配allMatch
try-catch finally执行顺序的例题
LVS four layer load balancing cluster (4) main methods of load balancing
【測試開發】自動化測試selenium(三)——unittest框架解析
Mobile communication exercises
Jumpserver installation
【测试开发】软件测试基础篇
Time complexity
大疆无人机飞控系统的原理、组成及各传感器的作用
EGO Planner代码解析----CMakeLists.txt和package.xml
Lambda end operation find and match findfirst
User and permission configuration in SQL Server database to ensure database security
不卷了!团队又一位成员离职了。。
2022 spring semester summary
【测试开发】博客系统——Loadrunner性能测试(发布博客功能 基准测试)
【测试开发】进阶篇——各种测试技术分类
Explain usage, field explanations, and optimization instances of MySQL
Spark optimization - data skew solution
LeetCode185. All employees with the top three highest wages in the Department (MySQL)
单片机:D/A 输出