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
1. Download the MySQL installation package (there...
Preface After a failover occurs, a common problem...
Usage scenarios For existing servers A and B, if ...
background We often use Chrome Dev Tools for deve...
MySQL is a relational database management system ...
The accessibility of web pages seems to be somethi...
theme Today I will teach you how to create a circ...
This article shares the specific code of js+canva...
Table of contents Build Vuex environment Summariz...
1. Introduction to MMM: MMM stands for Multi-Mast...
1. Introduction to mysqldump mysqldump is a logic...
Preface Recently, I have been busy dealing with s...
Table of contents Preface Add sudo write permissi...
1. Demand The base has 300 new servers, and needs...
Table of contents 1. Build the operating environm...