CSS line-height的如何继承的问题

An ·
更新时间:2024-09-20
· 819 次阅读

Line-height的如何继承?

写具体数值,如30px,则继承该值(比较好理解)写比例,如2/1.5,则继承该比例(比较好理解) 比如body中line-height设为2,则p标签继承line-height为2,则算出来的p标签line-height为font-size * 2 =32px; 写百分比,比如200%,则继承计算出来的值(考点)—当前的font-size * 200% 例子中:20 * 200% = 40px;

核心代码演示:

初始化

<style> body{ font-size: 20px; } p { background-color: #ccc; font-size: 16px; } </style> </head> <body> <p>这是一行文字</p> </body>

写具体数值

body{ font-size: 20px; line-height: 50px; } p { background-color: #ccc; font-size: 16px; }

写比例

body{ font-size: 20px; line-height: 1.5; } p { background-color: #ccc; font-size: 16px; }

写百分比 先算后继承!

body{ font-size: 20px; line-height: 200%; } p { background-color: #ccc; font-size: 16px; }

到此这篇关于CSS line-height的如何继承的问题的文章就介绍到这了,更多相关CSS line-height继承内容请搜索软件开发网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持软件开发网!



height 继承 line line-height CSS

需要 登录 后方可回复, 如果你还没有账号请 注册新账号