当前位置:网站首页>块级元素和行内元素
块级元素和行内元素
2020-11-09 12:27:00 【归子莫】
块级元素和行内元素
<!-- more -->
博客说明
文章所涉及的资料来自互联网整理和个人总结,意在于个人学习和经验汇总,如有什么地方侵权,请联系本人删除,谢谢!
行内元素和块级元素的区别:
行内元素:
- 与其他行内元素并排
- 不能设置宽高,默认的宽度就是文字的宽度
块级元素:
- 霸占一行,不能与其他任何元素并列。
- 能接受宽高,如果不设置宽度,那么宽度将默认变为父级的100%。
块级元素和行内元素的分类:
-
在HTML的角度来讲,标签分为:
-
文本级标签:p , span , a , b , i , u , em
-
容器级标签:div , h系列 , li , dt ,dd
p:里面只能放文字和图片和表单元素,p里面不能放h和ul,也不能放p。
从CSS的角度讲,CSS的分类和上面的很像,就p不一样:
行内元素:除了p之外,所有的文本级标签,都是行内元素。p是个文本级标签,但是是个块级元素。
块级元素:所有的容器级标签,都是块级元素,以及p标签。
块级元素和行内元素的相互转换:
通过display属性将块级元素(比如div)和行内元素进行相互转换。
-
display:inline;
那么这个标签将变为行内元素,即:
1,此时这个div将不能设置宽度和高度了。
2,此时这个div可以和其他行内元素并排了。
用display将行内元素(比如span)转行成块级元素。
-
display:block;
那么这个span标签将变为块级标签,即:
1,此时这个span能够设置宽度,高度。
2,此时这个span必须独占一行,其他元素无法与之并排。
3,如果不设置宽度,将占满父级。
感谢
万能的网络
版权声明
本文为[归子莫]所创,转载请带上原文链接,感谢
https://my.oschina.net/guizimo/blog/4708904
边栏推荐
- Method of creating flat panel simulator by Android studio
- 服务应用 ClockService安卓实现闹钟
- Flink 系例 之 Reduce
- 【分布式】分布式锁都有哪些实现方案?
- JVM learning (4) - garbage collector and memory allocation
- Wealth and freedom? Ant financial services suspended listing, valuation or decline after regulation
- Safety (miscellany)
- PAT_甲级_1074 Reversing Linked List
- A simple way to realize terminal text paste board
- 一个简单的能力,决定你是否会学习!
猜你喜欢
Python zero basics tutorial (01)
Kubernetes business log collection and monitoring
Complete set of linked list operations of data structure and algorithm series (3) (go)
Depth analysis based on synchronized lock
20201107第16课,使用Apache服务部署静态网站;使用Vsftpd服务传输文件
微信视频号播主排行榜2020年10月
Biden wins the US election! Python developers in Silicon Valley make fun of Ku Wang in this way
SQL Chapter 2 Chapter 3
JVM learning (6) - memory model and thread
SEO见风使舵,是对还是错?
随机推荐
[design pattern] Chapter 4: Builder mode is not so difficult
零基础IM开发入门(四):什么是IM系统的消息时序一致性?
Safety (miscellany)
How to query by page after 10 billion level data is divided into tables?
分库分表的 9种分布式主键ID 生成方案,挺全乎的
libssl对CentOS登录的影响
How to ensure that messages are not consumed repeatedly? (how to ensure the idempotent of message consumption)
Three practical skills of Medical Project Management
走进京东 | 中国空间技术研究院青年创新联盟成员莅临参观京东总部
JVM学习(四)-垃圾回收器和内存分配
Shoes? Forecasting stock market trends? Taobao second kill? Python means what you want
JVM learning (4) - garbage collector and memory allocation
Is SEO right or wrong?
Adobe experience design / XD 2020 software installation package (with installation tutorial)
Implement crud operation
Kubernetes business log collection and monitoring
Using stream to read and write files to process large files
Aren't you curious about how the CPU performs tasks?
Suning's practice of large scale alarm convergence and root cause location based on Knowledge Map
配置交换机Trunk接口流量本地优先转发(集群/堆叠)