Home > Web Front-end > CSS Tutorial > Intercept string using pure CSS3

Intercept string using pure CSS3

php中世界最好的语言
Release: 2018-06-13 14:04:23
Original
1946 people have browsed it

This time I will introduce to you what are the precautions for using pure CSS3 to intercept strings. The following is a practical case, let's take a look.

Code examples are as follows:

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.jb51.net/" />
<title>CSS</title>
<style type="text/css"> 
#first{
  width:120px;
  height:30px;
  background-color:#F30;
  overflow:hidden;
  text-overflow:clip;
  white-space:nowrap;
}
#second{
  width:120px;
  height:30px;
  background-color:#F30;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  margin-top:10px;
}
</style> 
</head>
<body>
<p id="first">QWEQWEQWEQWE</p> 
<p id="second">QWEQWEQWEQWE</p> 
</body>
</html>
Copy after login

Special note: white-space:nowrap and overflow:hidden cannot be omitted, otherwise the intercepted string will be invalid.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Develop a small program to create a pop-up menu function (with code)

Upgrade webpack to version 4.0 And install webpack-cli

The above is the detailed content of Intercept string using pure CSS3. 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