The property names often heard in web design: content, padding, border, margin, the CSS box model has all these properties. We can understand these properties by using a common thing in daily life - a box as a metaphor, so it is called the box model. The CSS box model is a thinking model used by CSS technology that is often used in web design. Introduction CSS (Cascading Style Sheet) can be translated as "Cascading Style Sheet" or "Cascading Style Sheet". It defines how to display HTML elements and is used to control the appearance of Web pages. By using CSS to separate the content and presentation of the page, work efficiency is greatly improved. CSS assumes that all HTML document elements generate a rectangular element box that describes the space occupied by the element in the HTML document layout, which can be figuratively regarded as a box. CSS has created a concept of "box model" around these boxes. By defining a series of box-related properties, it can greatly enrich and promote the performance and layout structure of each box and even the entire HTML document. For box elements, if there is no special setting, they always occupy an independent line by default, and their width is the width of the browser window. The elements before and after them, whether they are boxes or not, can only be arranged above or below them, that is, they are arranged cumulatively up and down. Each box in an HTML document can be seen as consisting of four parts from the inside to the outside, namely the content area (content), padding (padding), border (border) and margin (margin). CSS defines a series of related properties for the four parts. By setting these properties, the performance of the box can be enriched. CSS Box Model In CSS, we can regard all HTML elements as a box. We can take div as an example. In the browser inspector, we can also observe the appearance of the box model more intuitively as shown in the figure: 1. The composition of the box model: Content area: content (the blue area in the middle of the picture) Note the difference between the size of the box and the size of the box in the browser 2. Classification of box models: 1) content-box: div{ width: 100px;//Width of the content area height: 100px;//Height of the content area border: 5px solid pink; padding:10px; margin: 10px; } The width of the box: width + border-left + border-right + padding-left + padding-right 2) border-box: width:200px; //Width of the box height:200px; //Height of the box Height of the content area: height - border-top - border-bottom - padding-top - padding-bottom 3. Use of the box model Summarize This is the end of this article about the CSS box model that you should not be confused about. For more relevant CSS box model content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope that everyone will support 123WORDPRESS.COM in the future! |
<<: Mac+IDEA+Tomcat configuration steps
>>: How to prevent event bubbling in JavaScript
Preface This article mainly introduces the releva...
1. Update the yum source The PostgreSQL version o...
1. Use the SELECT clause to query multiple tables...
Table of contents Props comparison of class compo...
1. Download centos7 Download address: https://mir...
This article mainly introduces the process analys...
This article shares the specific code of JavaScri...
Style Sheets CSS (Cascading Style Sheets) is used...
Table of contents 1. beforeCreate and created fun...
Recently, I encountered a problem in the process ...
What is it? Spring Boot is a sub-project of the S...
Recently, when I was working on a front-end vue.j...
Preface: Timestamp fields are often used in MySQL...
Table of contents Preface What does yarn create d...
Preface nginx uses a multi-process model. When a ...