Ellipsis (CSS) displayed when the width is exceeded)

Source: Internet
Author: User

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 overflow: Den den attribute will be given to the container, and the line feed will not be displayed. OK! Next is the most exciting part. See the Code:

Code
  . List ul {
Font-size: 12px;
Font-family: simsun;
Text-align: left;
Line-Height: 18px;
Width: 11em;
Background: # FFF;
}
. List Li {
Height: 18px;
Overflow: hidden; // when a is opened, only the upper part is displayed.
Position: relative;
Padding-left: 1em;
Background: URL (...) No-repeat 3px 6px;
}
. List {
Display: block;
Padding-Right: 1em; // to accommodate Span
Background: URL (...) Right top no-Repeat;
Position: relative;
Zoom: 1;
Word-break: Break-all; // Chinese characters, letters, and numbers
}
. List a span {
Position: absolute; // span floating,
Right: 0em;
Bottom: 0; // span close to the bottom boundary
Height: 18px;
Width: 1em;
Background: # FFF; // the background color is the same as that of a to block span.
Overflow: hidden;
}

 

The Code may not be clear. Let's take a look:

 

I believe it is clear again.
This is a fascinating idea!
Source: http://bbs.blueidea.com/thread-2915238-1-1.html

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.