CSS text interception function to achieve code _ experience Exchange
Source: Internet
Author: User
The benefits are:
Compatible Ie,firefox,opera;
Conducive to the integrity of the content, SEO-friendly;
No background program processing;
You can adjust the length of the interception at the front desk.
A bad place:
Can not automatically determine the length of interception, when the characters are very short in Firefox will also generate the following ellipsis.
In addition, when setting the width of the interception, we should pay attention to, as far as possible, text interception complete.
Quote:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>css text interception </title>
<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>
Use CSS to achieve automatic interception of text, do not require the use of background programs and JS
Benefits are: conducive to content integrity, SEO-free, without the background process, you can adjust the length at the front to intercept.
<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= "#" > In addition, when setting the width of the interception, be aware that you should try to intercept the text as full </a></div>
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.