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属性 ...
随机推荐
- 爬虫-----selenium模块自动爬取网页资源
selenium介绍与使用 1 selenium介绍 什么是selenium?selenium是Python的一个第三方库,对外提供的接口可以操作浏览器,然后让浏览器完成自动化的操作. sel ...
- linux架构师之路!
目录 1.shell编程总结 2.python编程总结 3.网络基础总结 4.存储的基本知识 5.linux常用 架构学习目录 1.网站架构 2.架构师技术图谱 3.python之路 4.IBM技术主 ...
- Centos上传下载命令
[root@localhost ~]# rz -bash: rz: command not found //安装下载上传插件 [root@localhost ~]# yum -y install lr ...
- python处理Excel - xlrd xlwr openpyxl
python处理Excel - xlrd xlwr openpyxl 1 xlrd和xlwt Todo: 使用xlrd和xlwt读写Excel文件的方法和示例代码,待续... 参考链接: Creati ...
- Python数据分析matplotlib可视化之绘图
Matplotlib是一个基于python的2D画图库,能够用python脚本方便的画出折线图,直方图,功率谱图,散点图等常用图表,而且语法简单. Python中通过matplotlib模块的pypl ...
- MySql修改数据表的基本操作(DDL操作)
1.查看数据库的基本语句:show databases; 2.选择相应的数据库进入语法:use 数据库名; 3.查看数据库中的表语法:show tables; 4.查看表的基本结构语句:desc 表名 ...
- PPTP支持IPv6
pptp支持ipv6,谷歌资料不多,这里整理下 主要用来给ipv4访问ipv6资源的场景使用,客户端连接上pptp后会分配得到一个ipv6地址,通过此地址访问ipv6的资源 客户端网段在pptp. ...
- 常见mysql的慢查询优化方式
一,第一步.开启mysql慢查询 方式一: 修改配置文件 在 my.ini 增加几行: 主要是慢查询的定义时间(超过2秒就是慢查询),以及慢查询log日志记录( slow_query_log) 方 ...
- LR12脚本录制流程
准备工作: 工具:win7系统.loadrunner 12.Firefox浏览器.飞机订票系统. 打开飞机订票系统 开始录制脚本 步骤一:打开loadrunner(Virtual User Gener ...
- 【Codeforces Round】 #431 (Div. 2) 题解
Codeforces Round #431 (Div. 2) A. Odds and Ends time limit per test 1 second memory limit per test ...