Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set css to exceed the display ellipsis

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to set css beyond the display ellipsis, the article introduces in great detail, has a certain reference value, interested friends must read it!

Css setting exceeds the method of showing ellipsis: 1, use the "overflow:hidden;" statement to hide the excess part; 2, use the "text-overflow:ellipsis;" statement to show the ellipsis symbol to represent the hidden part when the text overflows the containing element.

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

There are two situations in which the css setting exceeds the display ellipsis

A single line of text overflows to show ellipses.

Multiline text overflows to show ellipses.

But the core code is the same: you need to use "overflow:hidden;" to hide the excess, and then use "text-overflow:ellipsis;" to display as an ellipsis when the text exceeds.

Overflow:hidden; does not display content that exceeds the size of the object, just hides the excess

Text-overflow:ellipsis; is displayed when the text object overflows. Of course, you can also set the property to clip to not display dots.

Implementation code

1. Single-line text overflow shows ellipsis.

* {margin: 0pxashing padding: 0px.box {width: 300pxashing height: 500pxashing margin: 50px auto;} .boxes {width:220px; overflow:hidden; white-space: nowrap Text-overflow:ellipsis;-oMutttext overflow flows

Css single-line text shows ellipsis beyond its length

Css single-line text shows ellipsis beyond its length

Effect picture:

2. Multi-line text overflow shows ellipsis.

* {margin: 0pxashing padding;} .box {width: 280px; height: 62px; margin: 50px auto; overflow: hidden; text-overflow: ellipsis Display:-webkit-box;-webkit-line-clamp: 3;-webkit-box-orient: vertical } css multi-line text shows ellipsis over length, and css multi-line text shows ellipsis over length.

The above is all the content of the article "how to set css beyond the display ellipsis". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 226

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report