1. CSS style solves the problem of displaying ellipsis when text is too long1. General styleGenerally, in CSS styles, when the width is not enough, a line break effect may occur. This effect is definitely not acceptable at some times, and you can modify the CSS style to solve this problem. <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>text-overflow</title> <link rel="stylesheet" type="text/css" href="http://unpkg.com/view-design/dist/styles/iview.css"> <script type="text/javascript" src="http://vuejs.org/js/vue.min.js"></script> <script type="text/javascript" src="http://unpkg.com/view-design/dist/iview.min.js"></script> <style type="text/css"> .demo-split { width: 500px; height: 100px; border: 1px solid #dcdee2; background: palegreen; } .demo-split-pane { padding: 10px; color: red; } </style> </head> <body> <div id="app"> <div class="demo-split"> <Split v-model="split"> <div slot="left" class="demo-split-pane"> Not using clip adaptive width</div> <div slot="right" class="demo-split-pane"> Not using ellipsis adaptive width</div> </Split> </div> </div> </body> <script type="text/javascript"> new Vue({ el: '#app', data() { return { split: 0.4 } } }) </script> </html> The width on the left side becomes smaller and the text wraps. The width on the right side becomes smaller and the text wraps. 2. The text is too long and displays ellipsis or truncation effect【Usually written as:】 <style type="text/css"> .test_demo_clip { text-overflow: clip; overflow: hidden; white-space: nowrap; width: 200px; background: palegreen; } .test_demo_ellipsis { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; width: 200px; background: palegreen; } </style> 【illustrate:】 text-overflow: indicates whether to display the ellipsis mark when the text overflows, ellipsis indicates the ellipsis effect, and clip indicates the clipping effect. overflow:hidden; Hide the overflowing text. white-space:nowrap; prohibits text wrapping. width: (optional) You can set a fixed value or set the display effect to adapt to the width. <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>text-overflow</title> <link rel="stylesheet" type="text/css" href="http://unpkg.com/view-design/dist/styles/iview.css"> <script type="text/javascript" src="http://vuejs.org/js/vue.min.js"></script> <script type="text/javascript" src="http://unpkg.com/view-design/dist/iview.min.js"></script> <style type="text/css"> .test_demo_clip { text-overflow: clip; overflow: hidden; white-space: nowrap; width: 200px; background: palegreen; } .test_demo_ellipsis { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; width: 200px; background: palegreen; } .test_demo_defined_Width_clip { text-overflow: clip; overflow: hidden; white-space: nowrap; background: bisque; } .test_demo_defined_Width_ellipsis { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; background: bisque; } .demo-split { width: 500px; height: 100px; border: 1px solid #dcdee2; background: palegreen; } .demo-split-pane { padding: 10px; } </style> </head> <body> <div id="app"> <h2>text-overflow : clip </h2> <div class="test_demo_clip"> Do not display ellipsis marks, but simply crop bars</div> <br> <h2>text-overflow : ellipsis </h2> <div class="test_demo_ellipsis"> When the text overflows the object, an ellipsis mark is displayed. <br> <h2>Custom width, adaptive size according to width</h2> <div class="demo-split"> <Split v-model="split"> <div slot="left" class="demo-split-pane"> <div class="test_demo_defined_Width_clip"> Use clip adaptive width</div> </div> <div slot="right" class="demo-split-pane"> <div class="test_demo_defined_Width_ellipsis"> Use ellipsis adaptive width</div> </div> </Split> </div> </div> </body> <script type="text/javascript"> new Vue({ el: '#app', data() { return { split: 0.4 } } }) </script> </html> clip shows the effect of cropping, and ellipsis shows the effect of ellipsis. Summarize The above is the CSS style that I introduced to you to solve the problem of displaying ellipsis when the text is too long. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! |
>>: Introduction to 10 Hooks in React
background PNG images take up more storage space ...
1. Nginx installation steps 1.1 Official website ...
The information on Baidu is so diverse that it...
0. Overview Zabbix is an extremely powerful ope...
Let me tell you about a recent case. A game log l...
I made a Dockerfile for openresty on centos7 and ...
The data backup operation is very easy. Execute t...
Today, when installing nginx on the cloud server,...
Table of contents 1. Background 2. Operation step...
Table of contents Overview Install Gulp.js Create...
How to configure custom path aliases in Vue In ou...
1. Understanding of transition attributes 1. The ...
Preface When I went to an interview at a company ...
Method 1 Copy code The code is as follows: documen...
There are many tags and elements in the HTML head ...