Home > Web Front-end > HTML Tutorial > css limits single line text input, use... to replace the excess part

css limits single line text input, use... to replace the excess part

WBOY
Release: 2016-11-30 23:59:40
Original
1401 people have browsed it

 In practical applications, it is often necessary to display only one line of text and not allow text wrapping to destroy the overall style. For example, 'name of product', 'introduction', etc. However, due to the different widths of the monitors, there may be situations where the text content provided in the background cannot be accommodated in one line of text. If the overflow text is hidden abruptly using overflow:hidden, the display effect will not be very good. At this time, the overflow text needs to be replaced with an ellipsis... Using js to intercept is a bit complicated. You can directly use css attributes to set it to achieve this effect.

 The css attributes that need to be added to the text object are as follows:

Casual solid color versatile shorts

.className{width: 60px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}

The displayed effect is as follows:

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