Detailed explanation of html box model
This time I will bring you a detailed explanation of the html box model. What are the precautions when using the html box model. The following is a practical case, let's take a look.
1.1. The size of the content area of the box—content width and content height—depends on several factors:
--Whether the element that generates the box has 'width' or 'height' set Attributes.
--Whether the box contains text and other boxes.
--Whether the box is a table, etc.
1.2. The background color of the box
--The background style of the padding and border areas is specified by the 'background' attribute of the element that generates (the box) . The margin background is always transparent
2. Margin attributes: 'margin-top', 'margin-right', 'margin-bottom' ', 'margin-left' and 'margin'
##2.1. The margin attribute specifies the width of the box's margin area--'margin'简写属性一次性设置四周的外边距,而其它外边距属性只设置它们各侧的。这些属性适用于所有元素,但非替换的行内元素上的垂直margin将不会产生任何效果
--<length> 指定一个固定宽度 --<percentage> 百分比根据生成盒的包含块的width来计算。注意,这一点对于'margin-top'和'margin-bottom'也适用。如果包含块的宽度取决于该元素,那么产生的布局在CSS 2.1是未定义的 --auto --margin属性允许负值,但可能存在具体实现限制
'margin-top', 'margin-bottom' Value: <margin-width> | inherit Initial: 0 Applies to: 除display类型为table系列中除了table-caption,table和inline-table以外的所有元素(译注:也就是说,table系列display值中,margin-只适用于table-caption, table, inline-table,其余的都不适用,但margin-对非table系列都适用) Inherited: no Percentages: 参照包含块的宽度 Media: visual Computed value: 指定的百分比或者绝对长度
'margin-right', 'margin-left' Value: <margin-width> | inherit Initial: 0 Applies to: 除display类型为table系列中除了table-caption,table和inline-table以外的所有元素(译注:也就是说,table系列display值中,margin-只适用于table-caption, table, inline-table,其余的都不适用,但margin-对非table系列都适用) Inherited: no Percentages: 参照包含块的宽度 Media: visual Computed value: 指定的百分比或者绝对长度
'margin' Value: <margin-width>{1,4} | inherit Initial: 见单独的各个属性 Applies to: 除display类型为table系列中除了table-caption,table和inline-table以外的所有元素(译注:也就是说,table系列display值中,margin-只适用于table-caption, table, inline-table,其余的都不适用,但margin-对非table系列都适用) Inherited: no Percentages: 参照包含块的宽度 Media: visual Computed value: 见单独的各个属性
----If one has a clearance (clearance Translation Note: refers to the gap formed by the clear attribute causing the position of the element to move). The upper margin of the element is adjacent to the lower margin. Its margin will be merged with the adjacent margin of the immediately adjacent sibling (element), but the merge It will no longer be merged with the lower margin of the parent block
How to quickly create html header code in sublime
What are the length units in css
CSS(Cascading Style Sheets) collection
The above is the detailed content of Detailed explanation of html box model. For more information, please follow other related articles on the PHP Chinese website!

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
