Home  >  Article  >  Web Front-end  >  How to limit the number of characters in css

How to limit the number of characters in css

零到壹度
零到壹度Original
2018-03-23 10:02:544047browse

This article mainly shares with you how to limit the number of characters in CSS, mainly in the form of code. I hope it can help everyone.

html part

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<p id="nr">
			我是显示的内容
我是显示的内容
我是显示的内容
		</p>
	</body>
</html>

css part

width:20px;
overflow: hidden;
text-overflow: ellipsis;
//限制字数显示
white-space: nowrap;
//后面出来省略号

Related recommendations:

css limits the number of displayed words, and the excess text length is represented by ellipses

How to implement CSS limit number of words

html5 tag uses css to limit the number of displayed lines (number of words)

The above is the detailed content of How to limit the number of characters in css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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