Preface Recently, I have been taking some time in the evening to read the book "CSS World". This book is very interesting and made me realize that CSS is not as simple as a few attribute styles. Yesterday I saw that in an inline block element, if the width is set to 0, the content in the element tag has a minimum width. The minimum width is different for Chinese characters and English characters. Chinese characters are divided by each Chinese character, and English characters are divided by English words. The beginning of the article The book gives an example of convex and concave, but does not explain it in detail. Below I will explain this code in detail. Code Operation <style> .ao ,.tu{ display: inline-block; width: 0; font-size: 14px; line-height: 18px; margin: 35px; color: skyblue; } .ao:before, .tu:before{ /* The style outside the border plays a prominent role, outline-color/style/width */ outline: 2px solid #cd0000; /* Specifies the font family of an element*/ font-family: Consolas, Monaco, monospace; } .ao:before{ content: "love you love"; } .tu{ /* Text direction from left to right, for reverse direction*/ direction: rtl; } .tu:before{ content: "I love you" } </style> </head> <body> <div> <span class="ao">I love mother</span> <span class="tu">I don't love you</span> <span>I love you</span> </div> </body> Results Code Interpretation Two span tags are used to show the concave and convex effects. The span tag is an inline element. If you are not familiar with the three styles, I will explain them later in the article. 1. First, convert it into an inline block element through display. The width is then set to 0 so that the span element has a minimum width. 2. Use a common pseudo-element before for the two pseudo-elements. Different contents of the pseudo-elements will have different line breaks, the outer border style will be red, and the font style will be specified. direction: rtl; is to make the text direction from right to left, and the protruding part is aligned with the concave opening. 3. The following "I love mother, but I don't love you" will be displayed after the content of the before element according to the bottom width value of the inline block element. Tag classification Block-level elements <address> defines the address Inline elements The <a> tag defines an anchor Inline block elements <button> Button End of the article To sum it up in one sentence, when the width of an inline block element is 0, the content inside the element has a minimum width value. You can also give it a try. If you have any questions, please leave a message in the comment area and learn together. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: Implementation of Mysql User Rights Management
>>: More popular and creative dark background web design examples
Table of contents Find the problem 1. How to remo...
SQL UNIQUE constraint The UNIQUE constraint uniqu...
There are two ways to deploy Angular projects wit...
In an unordered list ul>li, the symbol of an u...
emmm the name is just a random guess 2333 Preface...
Preface The notification bar component is a relat...
Table of contents Introduction Download and insta...
question In LINUX, periodic tasks are usually han...
In the vertical direction, you can set the alignm...
Preface By default, Nginx logs are written to a f...
We often see ads appear after a few seconds and t...
In Vue, we generally have front-end and back-end ...
mysql full backup 1. Enable binary log and separa...
A situation that often occurs in a project is tha...
When we work in a terminal or console, we may not...