Web Design applications: Using CSS word-cutting

Source: Internet
Author: User
Tags truncated
css| Design | Web page design

The word truncation is a disgusting question. In order to take care of performance needs, it is often necessary to cut short sentences that are too long, such as a headline in a list.

This is usually handled by programmers using background technology (a variety of popular languages, PHP, JSP, etc.) or foreground technology (JAVASCRIPT). I am personally inclined to use the foreground technology, because it is good for improving the affinity of Web pages (accessibility). In a non-desktop browser, users can more easily grasp the integrity of information.

Text-overflow is a property of CSS3 that truncates a long string and determines how the truncated part is displayed based on the value. At present, IE has implemented its support, opera also has a private attribute (-o-text-overflow) to its support, Firefox seems to be a step behind ... Both can be supported using the ellipsis value, replacing the truncated part with an ellipsis (i.e., ellipsis).

So, all you have to do is to set the width of the elements that need to be truncated and use them together with overflow to achieve the effect.

But Firefox doesn't support it, so you probably know what I'm going to do next. :)

First you can look at Yahoo some Daniel's solution: http://blog.360.yahoo.com/blog-ktYYK_s5fqJ2Hu1ryv2QSL0-?p=120. Daniel is Daniel, XBL and JavaScript are two-pronged.

Then, my solution is to use the pseudo class: After adding the ellipsis, and then positioning it to the right. The effect is a bit rough, but simple and clear, pure CSS implementation.

The specific process does not say, look at the case, interested people look at the source code, it is easy to understand.



Related Article

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.