Automatically add the ellipsis (CSS) based on the width of the string)

Source: Internet
Author: User
From: http://www.jb51.net/article/3622.htm

Key CSS code: Text-overflow: ellipsis; overflow: hidden; white-space: nowrap; padding: 2px

The following is an instance: Code
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<Title> new document </title>

<Style>
. CTL {
Table-layout: fixed
}
. Ctl td {text-overflow: ellipsis; overflow: hidden; white-space: nowrap; padding: 2px}
</Style>
</Head>

<Body>
<Table cellspacing = "0" cellpadding = "1" width = "100%" class = "CTL" border = 1>
<Colgroup>
<Col>
<Col width = "60">
</Colgroup>
<Tbody>
<Tr>
<TD> the title of the expanded associate professor's scholar doctor seems to be difficult, but the title of the 16th plane immediately expanded the title of the Associate Professor's scholar doctor to see it as difficult, but the 16th planes immediately </TD>
<TD> (1/1) </TD>
</Tr>
<Tr>
<TD> the title of the expanded associate professor's scholar doctor seems to be difficult, but the title of the 16th plane immediately expanded the title of the Associate Professor's scholar doctor to see it as difficult, but the 16th planes immediately </TD>
<TD> (1/1) </TD>
</Tr>
<Tr>
<TD> the title of the expanded associate professor's scholar doctor seems to be difficult, but the title of the 16th plane immediately expanded the title of the Associate Professor's scholar doctor to see it as difficult, but the 16th planes immediately </TD>
<TD> (1/1) </TD>
</Tr>
<Tr>
<TD> the title of the expanded associate professor's scholar doctor seems to be difficult, but the title of the 16th plane immediately expanded the title of the Associate Professor's scholar doctor to see it as difficult, but the 16th planes immediately </TD>
<TD> (1/1) </TD>
</Tr>
</Tbody>
</Table>
</Body>
</Html>

Example 2: How can I do this in <div> </div> or <li> </LI>? <! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<Title> new document </title>

<Style>

. CTL {}{ text-overflow: ellipsis; overflow: hidden; white-space: nowrap; padding: 2px}
</Style>
</Head>

<Body>
<Div class = "CTL" style = "width: 234; Height: 99; Background: cyan; "> the title is expanded. The Scholar-doctor of the Associate Professor sees it as hard but the title is expanded immediately. The Scholar-doctor of the Associate Professor sees it as hard but the title is 16th planes. </div>

<Ul class = "CTL" style = "width: 234; "> <li> the title of the expanded associate professor's scholar doctor seems to be difficult, but the title of the 16th plane immediately expanded the title of the Associate Professor's scholar doctor. It seems like the method is hard, but the 16th planes immediately </LI> <LI> the title of the expanded associate professor's scholar doctor seems to be difficult, but the title of the 16th plane immediately expanded the title of the Associate Professor's scholar doctor saw it as difficult, but the 16th planes immediately </LI> </ul>
</Body>

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.