How to set the excess part of a tag to ellipsis in css3

WBOY
Release: 2022-03-22 11:26:48
Original
2756 people have browsed it

Method: 1. Use the "overflow:hidden;" style to set the a label text beyond hiding; 2. Use "display: block;" to set the a label to a block-level element; 3. Use "text-overflow :ellipsis;" Just set the style of the excess part of the a tag to an ellipsis.

How to set the excess part of a tag to ellipsis in css3

The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.

How to set the excess part of a tag to ellipses in css3

The text-overflow attribute specifies how the text should be displayed when it overflows the element containing it. After overflow, you can set the text to be cut, to display an ellipsis (...), or to display a custom string (not supported by all browsers).

text-overflow: clip|ellipsis|string|initial|inherit;
Copy after login

clip Cut text.

ellipsis Displays ellipsis symbols ... to represent trimmed text.

The example is as follows:

a tag text can display ellipses by giving a fixed length and style

css:

 .cont {
            width: 180px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            display: block;
            float: left;
        }
Copy after login

html:

<a class="cont">这是一个名称很长的文档吧要测试超出功能</a>
Copy after login

The display effect is as shown in the figure:

How to set the excess part of a tag to ellipsis in css3

(Learning video sharing: css video tutorial)

The above is the detailed content of How to set the excess part of a tag to ellipsis in css3. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
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