About the code to replace CSS text with ellipses when it exceeds div or span

不言
Release: 2018-06-11 14:42:35
Original
2208 people have browsed it

In the project, we often need to display the text when it is too long, and replace the excess content with ellipses. How is this achieved based on CSS code? Below, the editor of Script House will give you a detailed explanation by analyzing this article. Friends who are interested can learn together

In the project, we often need to display the text when it is too long, and replace the excess content with ellipses:
The idea is:
First set the width, and then hide the excess part
If there is excess, display an ellipsis at the end
Let the text not wrap
Specific css The code is:

.title{ 
width:200px; 
overflow:hidden; 
text-overflow:ellipsis; 
white-space:nowrap; 
word-break:keep-all; 
}
Copy after login

There is no need to write the Html code, just a p or span class = "title".

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Summary of knowledge points about css front-end

Use 63 lines of HTML5 code to implement Snake game

The above is the detailed content of About the code to replace CSS text with ellipses when it exceeds div or span. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!