好惨啊,九点多了没事做还不能下班,坑爹的测试啊~~~

刚才拿这个问题调戏了下部门一位资深前端开发,结果发现,他居然不会,呵呵~~~

这里就说下吧

html:

 <div class="parent parent1">
父文字 line-height:150%
<p class="child">子文字</p>
</div>
<div class="parent parent2">
父文字 line-height:150em
<p class="child">子文字</p>
</div>
<div class="parent parent3">
父文字 line-height:1.5
<p class="child">子文字</p>
</div>

css:

 .parent{width: 800px;margin:20px auto;font-size: 18px;}
.parent1{line-height: 150%;}
.parent2{line-height: 1.5em;}
.parent3{line-height: 1.5;}
.child{
background: #f60;color:#fff;font-size: 40px;
}

令人期待的效果来了

第一个和第二个的子文字显示很不完整,子元素继承父元素的line-height(150%*18px=27px)

第三个才是我们需要的显示效果,子元素继承父元素的line-height(1.5*40px=30px)

结论:父元素line-height在150%和1.5em时候,子元素会继承父元素line-height大小值,在1.5时候,子元素会继承父元素line-height倍数

快十点了,好像快可以下班了,呵呵,废话比较多,只要记住那段红色的文字就好了

line-height 150%和1.5的区别的更多相关文章

  1. 设置line-height:1.5和line-height:150%或者line-height:150px的区别

    直接正题: 看一下line-height可能的值: 其实可以分为两类: (1)不带单位的(如line-height:1.5),这种是推荐使用的: (2)带单位的(如line-heigth:30px/1 ...

  2. jQuery中的height()、innerheight()、outerheight()的区别总结

    在前端jQuery代码中突然看到outerheight(),第一感觉就是,这是什么鬼?然后仔细查阅了一下,居然发现还有这么多相似的东西. 在jQuery中,获取元素高度的函数有3个,它们分别是heig ...

  3. jquery 对象的 height、innerHeight、outerHeight 的区别以及DOM 元素的 clientHeight、offsetHeight、scrollHeight、offsetTop、scrollTop

    前言:jquery 对象的 height.innerHeight.outerHeight,还有 DOM 元素的 clientHeight.offsetHeight.scrollHeight.offse ...

  4. height clientHeight scrollHeight offsetHeight的大致区别

    这主要是针对火狐浏览器来讲的: height:就是div的高度,就是style中设置的高度:在chrome中clientHeight是包含padding的,offsetHeight和clientHei ...

  5. stage.width/height和stage.stageWidth/stageHeight的区别

    stage.stageWidth和stage.stageHeight就是舞台的宽带和高度 一般默认打开宽带是550,高度是400 那么stage.stageWidth=550,stage.stageH ...

  6. width、height为auto或者100%的区别

    一.规则 1. 某div不设置宽度,那么width默认为auto. 2. 某子元素div的width为100%(或者设置为等于父元素宽度的具体值,比如父元素width为100px,子元素width也设 ...

  7. How to Take Control of Your Line Height in Outlook.com

    Reference to: http://www.emailonacid.com/blog/details/C13/line_height_and_outlook.com

  8. 深入了解css的行高Line Height属性

    什么是行间距? 古时候我们使用印刷机来出来文字.印刷出来的每个字,都位于独立的一个块中. 行间距,即传说中控制两行文字垂直距离的东东.在CSS中,line-height被用来控制行与行之间垂直距离. ...

  9. line-height:150% 和 line-height:1.5的区别

    line-height:150% 是继承父元素的距离 line-height:1.5  是计算各子元素的距离 1.当line - height 为百分比时: body{ font-size:14px; ...

随机推荐

  1. 问题:org.hibernate.LazyInitializationException: failed to lazily initialize

    今天搞了一上午,都在解决这个问题:org.hibernate.LazyInitializationException: failed to lazily initialize 原因很简单,是在非法的s ...

  2. WordCount-软件测试初体验

    github:https://github.com/skz12345/WordCount PSP2.1 PSP阶段 预估耗时(分钟) 实际耗时(分钟) Planning 计划 40 60 · Esti ...

  3. WebAPI 请求跨域问题

    本人采用的是利用CORS解决跨越问题. 首先利用Nuget 安装“microsoft.aspnet.webapi.cors”,如下图所示: 紧接着,在WebApiConfig文件中加入 config. ...

  4. [转]Marshaling a SAFEARRAY of Managed Structures by P/Invoke Part 2.

    1. Introduction. 1.1 In part 1 of this series of articles, I explained how managed arrays may be tra ...

  5. 【转载】在AspNetCore 中 使用Redis实现分布式缓存

    原文地址:https://www.cnblogs.com/szlblog/p/9045209.html AspNetCore 使用Redis实现分布式缓存 上一篇讲到了,Core的内置缓存:IMemo ...

  6. Unity苹果(iOS)内购接入(Unity内置IAP)

    https://www.jianshu.com/p/4045ebf81a1c Unity苹果(iOS)内购接入(Unity内置IAP) Kakarottog                       ...

  7. tcp设置超时重传

    TCP超时和重传的基础是怎样根据给定连接RTT设置RTO,若TCP先于RTT开始重传,可能会在网络中引入不必要的重复数据,反之,若延迟至远大于RTT的间隔发送重传数据,整体网络利用率会随之下降.由于R ...

  8. git相关问题处理

    1.在git push时无法提交代码,相对于git服务器上,本身代码可能不是最新的,因此提交的时候会报以下这个错误 Updates were rejected because the tip of y ...

  9. Java基础笔记(十七)——继承(续)final

    final  最终的 修饰类,此类不能被继承.final与访问修饰符public位置随意,在class前即可.public final class A{ } 修饰方法,此方法不能被子类重写,但可以被子 ...

  10. filter防止xxs攻击

    什么是XSS攻击? XSS攻击使用Javascript脚本注入进行攻击 例如在表单中注入: <script>location.href='http://www.itmayiedu.com' ...