This article makes a simple record of the implementation of this effect (including single-line text overflow ellipsis) in case you forget. Specifically, it is to achieve this text arrangement effect.
The HTML code is as follows:
The common CSS styles are as follows:
. container { margin:50px auto; width:328px;}. box { background: #f7f7f7;}. box-content { padding:20px;}. Box-content-title { margin:0
Sometimes the text is too much, but in order to be beautiful in the second line to display the ellipsis, instead of the first line beyond the immediate occurrence of the ellipsisHere is the CSS code:Overflow:hidden;text-overflow:ellipsis;//Display ellipsisDisplay:-webkit-box;-webkit-line-clamp:2;//the number of lines of text displayed by the block element-webkit-box-orient:vertical;:You can define it on the
DOCTYPE HTML>HTML>Head>MetaCharSet= "Utf-8">Metaname= "Author"content= "http://www.51texiao.cn/" />title>Titletitle>styletype= "Text/css">Div{Overflow:Hidden;White-space:nowrap;Height:30px;width:230px;Border:1px solid Red;Line-height:30px;Margin-top:10px;Text-overflow:ellipsis;}style>Head>Body>Divclass= "First">Every day is new, so life has to be different from yesterday!Div>Body>HTML>Copy CodeThe CSS imple
Form:table{table-layout:fixed;}}Ttd{White-space:nowrap;Overflow:hidden;Text-overflow:ellipsis;}}This method is used to solve the problem of aesthetic appearance when there are too many contents of table cells, mainly involving 4 CSS styles:1. table-layout:fixed because the default value of Table-layout is auto, that is, the width of the table will depend on the size of its content, if the volume of the content can not be estimated, then the final form
can be implemented, but with the-webkit-private property. I have solved it with JS. The code is as follows:Text-overflow:-o-ellipsis-lastline;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;- webkit-line-clamp:2;-webkit-box-orient:vertical;or JavaScript can do it.For example, you only want to display the first 20 words, the following text is replaced with ellipses, JS code is as follows:var str = ' Only show 20 text only show 20 text only s
It is a practical function to use CSS to intercept strings and display them as ellipsis. It is used by the CSS front-end for processing to reduce the waste of server resources and make the webpage faster, however, sometimes, due to the compatibility of the browser, the processing methods of CSS string Truncation in IE
; Position:absolute; bottom:0; right:0; padding:0 20px 1px 45px; Background:url (Http://css88.b0.upaiyun.com/css88/2014/09/ellipsis_bg.png) repeat-y;}Note that: 1: Set hight is an integer multiple of line-hight, so as to prevent text from overflowing under the box, exposing some of the residual words:2: Pseudo-class: After is set to position:absolute positioning, the purpose is to let the inserted background picture overlay in the bottom right corner of the text box, simulate over
First, the DIV section1 Body > 2 Div > Multi-line display how to solve, after a Google, I found a chrome API can solve the above mentioned requirements-webkit-line-clampDiv >3 body>Then, the CSS Section1. Single line1 Div {2 width:150px; 3 Overflow:hidden; 4 text-overflow:ellipsis; 5 display:-webkit-box; 6 -webkit-line-clamp:2; 7 -webkit-box-orient:vertical; 8 background-color:lightcoral; 92. Multi-lineThe m
HTML code:CSS code:div{Basic definition of width:200px;/* container */height:200px;}/* Style under IE */P span{Display:block;width:200px;/* definition of width, modified according to situation */Overflow:hidden;White-space:nowrap;Text-overflow:ellipsis;}/* Style under FF */P{clear:both;}P span{Float:left;max-width:175px; /*ie cannot interpret this property , and FF can */}p:after{Content: "...";}Turn CSS single-line overflow text display
Html.css overflow, css overflow ellipsis
I have been working hard and want to be with you. Now, it is impossible to be with you. Everyone once insisted on it. Finally, the person who gave up should give up. Maybe when you recall your youth, I am not the main character, not even the supporting role, but you are my whole youth.I have been working hard and want to be with you. Now, it is impossible to be with
CSS controls the overflow of LI line characters, which is replaced by ellipsis. cssliShow content 2 Show content 4, show content 4, show content 4, show content 4
In IE we simply use the CSS property of Text-overflow to implement the text overflow ellipsis.
Cases
The code is as follows
Copy Code
. entry_title{White-space:nowrap;Overflow:hidden;Text-overflow:ellipsis;}
But the browser outside IE is not, but you can use PHP mb_strimwidth, but also in accordance with the Chinese 2 bytes, English 1 bytes of the calculation, and if
Usage: Apply Width= "" at the same time in CSS; Overflow:hidden; Text-overflow:ellipsis; White-space:nowrap to achieve the effect.
Width= ""; Define display width
Overflow:hidden; Overflow hidden
Text-overflow:ellipsis ellipses Display overflow text content
White-space:nowrap; Force text to appear on one line
Use width to refer to it's good width and overflow:hidden; hide the excess content.
Add text-overflow:ellipsis to IE, add the same as abov
, the height is twice times higher than the line Css:. caption { Overflow:hidden; text-overflow:ellipsis; Display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; Color: #999999; line-height:15px;// height:30px;///* 2 lines hidden twice times, three lines hidden three times times */}49.CSS---Set multiple lines of text beyond the display ellipsis
HTML codeul> Li>ahref=""Target= "_blank">I am article 1, now the title is too long, use CSS plus ellipsisa>Li> Li>ahref=""Target= "_blank">Article 2a>Li> Li>ahref=""Target= "_blank">Article 3a>Li>ul>CSS Codeul{width:160px;background:Silver;/*the list style position changes to internal so that the image takes effect*/list-style-position:inside;List-style-image:URL (".. /source/bullet.png ");}Li{/*No
Code: Overflow:hidden;White-space:nowrap; Text-overflow:ellipsis;Key code: text-overflow:ellipsis;Explanation: The simple understanding is that I want to limit the text to one line (white-space:nowrap;), that the line is bound (width), and that the part of your overflow is to be hidden (overflow:hidden;), and then an ellipsis ( text-overflow:ellipsis).Text-ellipsis is a special style, and the explanation is
When I visited the Hemin blog, I saw an interview question. I checked the effect of displaying the ellipsis over the width and found this CSS version on the Internet. Of course, there are also JS version solutions, which are simple, but this idea is exquisite and worth collecting!The basic principle is: when the text content in the container exceeds the width of the container, the text will wrap, and an ove
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.