当前位置:网站首页>块级元素和行内元素
块级元素和行内元素
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
边栏推荐
- Shoes? Forecasting stock market trends? Taobao second kill? Python means what you want
- 零基础IM开发入门(四):什么是IM系统的消息时序一致性?
- How to use function framework to develop large web application
- “开源软件供应链点亮计划 - 暑期 2020”公布结果 基于 ChubaoFS 开发的项目获得最佳质量奖
- Navigation component of Android architecture (2)
- Glsb involves load balancing algorithm
- Impact of libssl on CentOS login
- 块级元素和行内元素
- Wealth and freedom? Ant financial services suspended listing, valuation or decline after regulation
- Download Netease cloud music 10W + music library with Python
猜你喜欢

Analysis of the source code of ThinkPHP facade

Biden wins the US election! Python developers in Silicon Valley make fun of Ku Wang in this way

Stack & queue (go) of data structure and algorithm series

iPhone“连到系统上的设备没有发挥作用”原因分析及解决方法 20200105

VisualStudio(Mac)安装过程笔记

Mapstructure detoxifies object mapping

技美那么贵,不如找顾问 | AALab企业顾问业务

SQL statement to achieve the number of daffodils

Interface tests how to pass files in post requests

导师制Unity网课 双十一优惠报名进行中
随机推荐
Nine kinds of distributed primary key ID generation schemes of sub database and sub table are quite comprehensive
Adobe experience design / XD 2020 software installation package (with installation tutorial)
Setting up a proxy for the WGet command
On the calculation of non interaction polarizability
FGC online service troubleshooting, this is enough!
Is SEO right or wrong?
Front end code style practice prettier + eslint + git hook + lint staged
块级元素和行内元素
JVM学习(六)-内存模型和线程
实现商品CRUD操作
nodejs学习笔记(慕课网nodejs从零开发web Server博客项目)
jsliang 求职系列 - 08 - 手写 Promise
Review of hot spots of last week (11.2-11.8)
Ali, Tencent, Baidu, Netease, meituan Android interview experience sharing, got Baidu, Tencent offer
Pay attention to the request forwarding problem of. Net core
Recommended tools for Mac
Chrome browser engine blink & V8
From coding, network transmission, architecture design, Tencent cloud high quality, high availability real-time audio and video technology practice
Jsliang job series - 08 - handwritten promise
Analysis of the source code of ThinkPHP facade
