


How to implement text overflow hiding and display ellipsis effect in CSS3
This article mainly introduces css3 method to hide text overflow and display ellipsis effect.
During our front-end page development process, when there is too much text content, in order to improve the user experience and make it easier for users to read, we need to implement the effect of text overflow, hiding and displaying ellipses. Obviously the ellipsis means that there is a lot of content behind that is not shown. So for front-end novices, they may not know how to achieve this effect.
Below we will use a simple code example to introduce the effect of using css3 to hide text overflow and display the ellipsis .
The code example is as follows:
<!DOCTYPE html> <html> <head> <title>Css3实现文本溢出隐藏效果</title> <meta charset="utf-8"/> <style type="text/css"> .main .one p { width: 500px; text-indent: 3em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } .main .one p:hover { text-overflow: inherit; overflow: visible; white-space: inherit; } </style> </head> <body> <div class="main"> <div class="one"> <p>PHP(外文名:PHP: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言。语法吸收了C语言、Java和Perl的特点,利于学习,使用广泛,主要适用于Web开发领域。PHP 独特的语法混合了C、Java、Perl以及PHP自创的语法。它可以比CGI或者Perl更快速地执行动态网页。用PHP做出的动态页面与其他的编程语言相比,PHP是将程序嵌入到HTML(标准通用标记语言下的一个应用)文档中去执行,执行效率比完全生成HTML标记的CGI要高许多;PHP还可以执行编译后代码,编译可以达到加密和优化代码运行,使代码运行更快。</p> </div> </div> </body> </html>
Introduction to related css attributes:
text-indent The attribute specifies the text block The indentation of the first line of text.
white-space Property sets how to handle white space within the element.
text-overflow Properties specify what happens when text overflows the containing element.
overflow The attribute specifies what happens when content overflows the element box.
The effect of the above code when accessed at the front desk is as follows:
This article is about the method of using css3 to hide text overflow and display the ellipsis effect. I hope it will help Friends in need help!
If you want to learn more about front-end related knowledge, you can follow the PHP Chinese website CSS3 Video Tutorial, CSS Video Tutorial, Bootstrap Tutorial, etc. Related tutorials, everyone is welcome to refer to and study!
The above is the detailed content of How to implement text overflow hiding and display ellipsis effect in CSS3. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











How to achieve wave effect with pure CSS3? This article will introduce to you how to use SVG and CSS animation to create wave effects. I hope it will be helpful to you!

This article will show you how to use CSS to easily realize various weird-shaped buttons that appear frequently. I hope it will be helpful to you!

Two methods: 1. Using the display attribute, just add the "display:none;" style to the element. 2. Use the position and top attributes to set the absolute positioning of the element to hide the element. Just add the "position:absolute;top:-9999px;" style to the element.

In CSS, you can use the border-image attribute to achieve a lace border. The border-image attribute can use images to create borders, that is, add a background image to the border. You only need to specify the background image as a lace style; the syntax "border-image: url (image path) offsets the image border width inward. Whether outset is repeated;".

How to create text carousel and image carousel? The first thing everyone thinks of is whether to use js. In fact, text carousel and image carousel can also be realized using pure CSS. Let’s take a look at the implementation method. I hope it will be helpful to everyone!

Implementation method: 1. Use the ":active" selector to select the state of the mouse click on the picture; 2. Use the transform attribute and scale() function to achieve the picture magnification effect, the syntax "img:active {transform: scale(x-axis magnification, y Axis magnification);}".

In CSS3, you can use the "animation-timing-function" attribute to set the animation rotation speed. This attribute is used to specify how the animation will complete a cycle and set the speed curve of the animation. The syntax is "element {animation-timing-function: speed attribute value;}".

CSS3 linear gradient can realize triangles; just create a 45-degree linear gradient and set the gradient color to two fixed colors, one is the color of the triangle and the other is transparent color. The syntax "linear-gradient(45deg, color value , color value 50%, transparent color 50%, transparent color 100%)".
