继续开始我的css之旅吧。今天我们来说什么啊。构思了两天还是没有什么思路,但是学习的步伐我们不能停止下来。还是按照之前的计划来讲讲display,在讲这个之前我们还是按照老规矩来扯扯蛋,步子不能够迈大了。废话不说了。
问大家一个问题哈?块级元素和行级元素,你们知道吗?
什么是块级元素了?(div)是块级元素 什么是行级元素?(span)你能看出他们两则的区别吗? 先上图
可能有时候大家不是特别的注意他们直接的区别。下面我们来说一下他们具体的特性:
块级元素:
1:块级元素会独占一行,其宽度自动填满其父元素宽度
2 :块级元素可以设置 width, height属性。【注意:块级元素即使设置了宽度,仍然是独占一行的】
3:块级元素可以设置margin 和 padding。
行级元素:
1:行内元素不会独占一行,相邻的行内元素会排列在同一行里,知道一行排不下,才会换行,其宽度随元素的内容而变化
2:行内元素设置width, height无效
3: 行内元素的水平方向的padding-left,padding-right,margin-left,margin-right 都产生边距效果,但是竖直方向的padding-top,padding-bottom,margin-top,margin-bottom都不会产生边距效果换句话说就是 水平方向有效,竖直方向无效
前面说了一个简单的例子现在能够看到他们其中存在的区别了吧。说道这里可能要需要补充 一点就是这个元素是个四不像的东西,可变元素。怎么判断他到底是什么( 可变元素需要根据上下文的语境来决定他到底是块还是行)通俗点讲:
你说了这么多东西和我们要讲的东西有半毛钱的关系,下面我们就来说说我们要讲的到底有几毛钱的关系。到底有没有关系了。如果没有关系我们说这个又有什么意义。
其实你可以反过来想其实我们整个HTML页面不就是行级和块级,最主要的是他们可以通过display:inline|block 相互的转换,现在知道他们有什么卵关系了吧。
既然有关系了,那我们就需要好好的理一理他们直接深刻的关系。有没有很激动啊。
其实他们的关系很复杂我们就讲讲几个比较简单的比较常用的,如果要深究的话建议自己去看看书.
下面我们来说Display这个东西属性太多了,没有办法一个一个说,我们来说说关键的几个none、block、inline、inline-block,其实也是平时我们说的最多的。
(1):inline
这个就是文字和图片会经常用到的,我们可以打一个比方就是,他就是瓶子里面的液体,液体的特点就是没有形状没有大小的。他的大小完全是由装他的容器来决定的。
其实块和行是可以相互切换的,但是这里面有问题: 这个属性用于定义建立布局时元素生成的显示框类型。对于 HTML 等文档类型,如果使用 display 不谨慎会很危险,因为可能违反 HTML 中已经定义的显示层次结构。他会破坏文档的结构所以请慎用。
哪有人就会问,那如果我要给他设计高度和宽度怎么办?
其实这个吗?我们下一章会介绍。这个先给大家看一个效果。如何实现发现没有float这个属性
inline元素的特点:
和其他元素都在一行上;
高,行高及顶和底边距不可改变;
宽度就是它的文字或图片的宽度,不可改变。
(2)Block:
大家看看和上面的截图的却别是什么?内容的宽度?看见没有。现在能不能够理解到之前说的他的宽度和高度的区别了。其实我的理解Block就是一个盒子模型,他需要完全遵循盒子模型的特点。不懂得化请参考上一个节。谢谢
Block特点
总是在新行上开始;
高度,行高以及顶和底边距都可控制;
宽度缺省是它的容器的100%,除非设定一个宽度
请重点关注一下加粗的部分。
(3):inline-block:
inline-block顾名思义,它既有inline的特性,又有block的特性,大家可以想想一般的button、input是什么样子的。 那button举例子。我们在页面中输入若干个

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools