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 Common version introduction Com...
html <div class="totop" v-show="...
The road ahead is long and arduous, but I will co...
Table of contents 1. Introduction 2. Customize ta...
Table of contents Classic approach question Furth...
This article shares the specific code of native j...
1. Download address: http://dev.mysql.com/downloa...
The general way of writing is as follows: XML/HTM...
The full name of SSH is Secure SHell. By using SS...
Reinventing the wheel, here we use repackaging to...
Table of contents 1. Introduction 2. Scenario 3. ...
This article records the installation and configu...
Table of contents 1. Download the system image fi...
1. Test environment name Version centos 7.6 docke...
In this article, I will explain in detail how to ...