在本文中,我们将看到如何在 CSS 中设置文本溢出属性。 text-overflow 属性用于指定某些文本已溢出并隐藏在用户视野之外。 text-overflow 属性只影响溢出块容器元素的内容。
句法:
text-overflow: clip| ellipsis
适当的价值:
- 剪辑:文本被剪辑,无法看到。这是默认值。
- 省略号:文本被剪切,被剪切的文本表示为 ‘…’ 。
注意: CSS 中的white-space 属性用于控制您将在以下示例中遇到的文本换行和空格。
示例 1:使用剪辑属性值。
HTML
Welcome to GeeksforGeeks
Text overflow: Clip
A Computer Science portal for
geeks. It contains well written,
well thought and well explained
computer science and programming
articles, quizzes and Gate
preparation Notes.
HTML
Welcome to GeeksforGeeks
Text overflow: ellipsis
A Computer Science portal for geeks.
It contains well written, well thought
and well explained computer science
and programming articles, quizzes
and Gate preparation Notes.
Aman Rathod
输出:
示例 2:使用省略号属性值。
HTML
Welcome to GeeksforGeeks
Text overflow: ellipsis
A Computer Science portal for geeks.
It contains well written, well thought
and well explained computer science
and programming articles, quizzes
and Gate preparation Notes.
Aman Rathod
输出: