line-height的高度机理
1.元素高度从何而来?是由里面的文字撑开的?

<!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>Document</title>
<style>
*{margin: 0;padding: 0;}
.test1{font-size: 0;line-height: 36px;border: 1px solid red;background: gray;}
.test2{font-size: 36px;line-height: 0;border: 1px solid red;background: gray;}
</style>
</head>
<body>
<div class="test1">测试</div>
<br>
<div class="test2">测试</div>
<!-- 从效果图中可看出,元素高度是由line-height决定的 -->
</body>
</html>
2.如果行框盒子里面有多个不同高度的内联盒子?
<!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>Document</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<style>
*{margin: 0;padding: 0;}
.em{line-height: 80px;}
</style>
</head>
<body>
<div id="app">
这是一行普通的文字,这里有个<em class="em">em</em>标签。
</div>
<!-- 如果行框盒子里面有多个不同行高的内联盒子?
原则上是由最高的那个内联盒子的高度决定的,但如vertical-align这样的属性可能会改变行框盒子高度
-->
</body>
</html>
3.父级元素line-height:1.5与line-height:150%/1.5em的区别
在计算上无差别,都是fontSize*1.5,但实际上有区别

<!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>Document</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<style>
*{margin: 0;padding: 0;}
.app{line-height: 1.5}
/* 当父级元素line-height:1.5时,子元素的高度是用自己的fontSize*1.5得到自己的高度 */
.val{font-size: 60px}
</style>
</head>
<body>
<div class="app">
<p>line-height:1.5</p>
<p class="val">我的font-size为60px</p>
</div>
</body>
</html>

<!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>Document</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<style>
*{margin: 0;padding: 0;}
.app{line-height: 150%}
/* 当父级元素line-height:150时,子元素的高度是用父级的fontSize*1.5得到自己的高度 */
.val{font-size: 60px}
</style>
</head>
<body>
<div class="app">
<p>line-height:1.5</p>
<p class="val">我的font-size为60px</p>
</div>
</body>
</html>
line-height的高度机理的更多相关文章
- html的height:100%;高度是多少
html的height:100%;高度是多少 html设置height:100%;表示一屏高度,类似于100vh.未设置则根据子元素的高度来自适应高.在实际应用中,设置页面高度为1屏幕高度通常设置: ...
- 使用 <embed> 标签显示 flash文件(swf)格式 ,如何设置 width 和 height 宽度,高度.
1. embed 标签 支持 .swf 格式. .flv 的不支持. 2. 通常情况下, 网站中上传 多个 flash文件. 它的默认大小是不一样的. 而且 可以 宽度 大于 高度(横向的) ...
- [LeetCode] Queue Reconstruction by Height 根据高度重建队列
Suppose you have a random list of people standing in a queue. Each person is described by a pair of ...
- Div Height设置高度后不能自适应
解决方法$("#div1").css("height", "");
- div height 自适应高度 占满剩余高度的方法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- [LeetCode] 406. Queue Reconstruction by Height 根据高度重建队列
Suppose you have a random list of people standing in a queue. Each person is described by a pair of ...
- 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
- 深入了解css的行高Line Height属性
什么是行间距? 古时候我们使用印刷机来出来文字.印刷出来的每个字,都位于独立的一个块中. 行间距,即传说中控制两行文字垂直距离的东东.在CSS中,line-height被用来控制行与行之间垂直距离. ...
- 浅析CSS中的BFC和IFC
1. 为什么会有BFC和IFC 首先要先了解两个概念:Box和formatting context: Box:CSS渲染的时候是以Box作为渲染的基本单位.Box的类型由元素的类型和display属性 ...
随机推荐
- urllib库的应用及简单爬虫的编写
1.urllib库基础 1.1爬虫的异常处理 常见状态码及含义 301 Moved Permanently:重定向到新的URL,永久性 302 Found:重定向到临时的URL,非永久性 304 No ...
- LG3369 普通平衡树
题意 维护一些数,其中需要提供以下操作: 1.插入\(x\) 2.删除\(x\)(若有多个相同的数,只删除一个) 3.查询\(x\)的排名(排名定义为比当前数小的数的个数\(+1\)) 4.查询排名为 ...
- 解决fastDFS客户端连接超时问题
1.修改storage.conf配置tracker_server的ip为外网ip 2.开放23000端口
- PyQt5之使用Qt下的designer工具将.ui文件转换成.py文件后添加什么东西后方可运行
首先证明我是加了那些鬼东西以后可以成功运行的. 然后来叙述一下我的过程. 这是一个.ui文件生成的.py文件.(把主要的内容省去了,但是没有影响结构) # -*- coding: utf-8 -*- ...
- 使用springmvc进行文件的上传和下载
文件的上传 SpringMVC支持文件上传组件,commons-fileupload,commons-fileupload依赖commons-io组件 配置步骤说明 第一步:导入包 commons-f ...
- 2种方式解决vue路由跳转未匹配相应路由避免出现空白页面或者指定404页面
https://www.cnblogs.com/goloving/p/9254084.html https://www.cnblogs.com/goloving/p/9254084.html 1.路由 ...
- How to Preloading content with rel preload
The preload value of the <link> element's rel attribute allows you to write declarative fetch ...
- 在userMapper.xml文件中模糊查询的常用的3种方法
在userMapper.xml文件中新建映射sql的标签 <!-- ******************** 模糊查询的常用的3种方式:********************* --> ...
- asp.net 去掉小数点后面多余的0,本身为0则不显示
很多时候,比如gridview内,不想现实从数据库带出的多余小数 ,比如 4.01000 ,可显示为 4.01 如果是 0.00000, 则显示为空白 /// <summary> /// ...
- Python练习:小程序,列车出票程序
# 需求:列车某结车厢座位有15行,5列,初始状态均为'有票',当乘客选了座次,下单后,变更为'已售' # 下单时,要显示所有座位的状态(有票or已售) # 下单完毕后,显示下单后的座位状态. lin ...