CSS out of text with ellipsis display compatible with Firefox IE6 IE7

Source: Internet
Author: User

CSS settings text overflow does not show or display ellipses, only a certain length of text, IE9 just set

The code is as follows Copy Code

Div{white-space:nowrap;text-overflow:none;}

Or

The code is as follows Copy Code

Div{white-space:nowrap;text-overflow:ellipsis;}

, you need to increase the width setting in ie6,ie7 to take effect

The code is as follows Copy Code

div{white-space:nowrap;text-overflow:ellipsis;*width:100px}


Instance 1

The code is as follows Copy Code

<style type= "Text/css" >
Body{font-size:13px;color: #8c966b;}
div{clear:both;width:340px;border:1px solid #333; margin:3px;padding:3px;}
Div a{color: #8c966b; text-decoration:none;}
Div A:hover{text-decoration:underline;}
Div A{display:block;width:310px;white-space:nowrap;overflow:hidden;float:left;
-o-text-overflow:ellipsis; * For Opera * *
Text-overflow:ellipsis; /* for IE *
}
Div:after{content: "...";p adding-left:3px;font-size:12px;} * For Firefox/*
</style>
<body>
<div><a href= "" > Use CSS to achieve automatic interception of text, do not require the use of background programs and JS </a></div>
<div><a href= "" > Benefits are: Conducive to content integrity, conducive to SEO, without the background program processing, can be at the front of the time to adjust the length of interception. </a></div>
<div><a href= "" > Bad Place: Can not automatically judge the length of interception, when the characters are very short in Firefox will also generate the following ellipsis. </a></div>
<div><a href= "" > Also, when setting the width of the interception, be aware that you should try to intercept the text completely </a></div>
</body>

Instance 2

The code is as follows Copy Code

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" >

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">

<title>css Write Ellipsis method </title>

<style>

UL {

width:300px; width of/*ul * *

margin:40px Auto;

padding:12px 4px 12px 24px;

border:1px solid #D4D4D4;

Background: #F1F1F1;

List-style:none;

}

Li {

MARGIN:12PX 0;

}

/* IE Only * *

Li a {

Display:block;

width:220px; /* Li Width This control shows how many words to display after ... If the width is greater than the number of words, it will not show ... The * *

Overflow:hidden;

White-space:nowrap;

-o-text-overflow:ellipsis;

Text-overflow:ellipsis;

}

/* Firefox only * *

Li:not (p) {

Clear:both;

}

Li:not (p) a {

max-width:170px; /* Only FF identification * *

Float:left;

}

Li:not (P): after {

Content: "...";

Float:left;

width:25px;

padding-left:5px;

Color: #000;

}

</style>

<body>

<ul>

<li><a href= "#" > Design staff must read: Impact SEO page Production details </a></li>

<li><a href= "#" > Design staff must read: Impact SEO page Production details </a></li>

<li><a href= "#" > Design staff must read: Impact SEO page Production details </a></li>

<li><a href= "#" > Design staff must read: Impact SEO page Production details </a></li>

<li><a href= "#" > Design staff must read: Impact SEO page Production details </a></li>

<li><a href= "#" > Design staff must read: Impact SEO page Production details </a></li>

<li><a href= "#" > Design staff must read: Impact SEO page Production details </a></li>

</ul>

</body>

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.