This article is suitable for beginners of css. For those who have mastered css, you can also use this article to review the knowledge.
Through practice, the author believes that in some cases, css code can be more concise. In most cases, it is caused by the fact that new users cannot simplify the writing of element code with multiple attributes.
Simplified code is of great benefit to web pages, which improves the access speed of visitors and allows search engines to capture key content of web pages. Let's take a look at the simplified code I have summarized below:
Reference content is as follows: 1. Margin & Padding Example 1: . Div { Margin-top: 10px; Margin-right: 5px; Margin-bottom: 30px; Margin-left: 0px; } |
The simplified code is as follows:
Reference content is as follows: . Div {margin: 10px 5px 30px 0 ;}) Example 2: . Div { Margin-top: 10ox; Margin-right: 20px; Margin-bottom: 0; Margin-left: 20px; } |
Simplified code:
Reference content is as follows: . Div { Margin: 10px 20px 0; } Example 3: . Div { Margin-top: 0; Margin-right: auto; Margin-bottom: 0; Margin-left: auto; } |
Simplified code:
Reference content is as follows: . Div { Margin: 0 auto; } Example 4: . Div { Margin-top: 50px; Margin-right: 50px; Margin-bottom: 50px; Margin-left: 50px; } |
- Three pages in total:
- Previous Page
- 1
- 2
- 3
- Next Page