Preface When I was working on a project recently, the font size of the UI design was 10px. When I looked at the renderings, I found that the font size was still quite large. When I changed it to 12px, the font size was still the same. When I changed it to 14px, the font size became larger. I found a pattern and realized that in order to let users see the font clearly, the browser set the minimum setting to 12px. what to do? Design is 10px? The final effect diagram is as follows: Rendering Rendering Rendering When I searched Baidu, the experts said that using Conversely, you can put the red dot and the text on two divs. The red dot controls the width and height, and the font can be reduced by using transform: scale to meet the needs. The specific implementation code is as follows: <div v-if="cartNum>=1" class="cartData"> <div class="Num" v-if="cartNum>=1&&cartNum<=99">{{cartNum}}</div> <div class="Num" v-else-if="cartNum>99">99+</div> </div> CSS part: .cartData{ height: .75rem; min-width: .75rem; border-radius: .375rem; background: red; color: white; text-align: center; line-height: .75rem; } .Num{ font-size: 20px; -webkit-transform: scale(0.5); } The font size above is 14*0.8 = 11.2px, which can be adjusted according to needs. Writing it this way alone will not be compatible with IE and FF, so here is another compatible way to write it: .Num{ font-size: 14px; -webkit-transform: scale(0.8); } .Numsize-font{ font-size: 14*0.8px; } Notice: Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM. |
<<: Specific steps to use vant framework in WeChat applet
1. Add fields: alter table table name ADD field n...
Preface A classmate is investigating MLSQL Stack&...
Preface As we all know, "How to vertically c...
This article example shares the specific code of ...
As more and more Docker images are used, there ne...
Table of contents Zabbix monitors Nginx Zabbix mo...
Table of contents 1. Solution 2. Let the browser ...
Preface Tomcat is an excellent Java container, bu...
There are many differences between IE6 and IE7 in ...
1. Overview The Promise object is a specification...
When a request is sent to your server to display ...
Starting from this section, we will explain the i...
MYSQL is case sensitive Seeing the words is belie...
1. What is a virtual host? Virtual hosts use spec...
As the title says, otherwise when the page is revi...