Why Isn't My `text-overflow: ellipsis` Working?

Mary-Kate Olsen
Release: 2024-11-10 19:51:03
Original
582 people have browsed it

Why Isn't My `text-overflow: ellipsis` Working?

text-overflow: ellipsis Not Functioning

In an attempt to make a span shrink with an ellipsis when the browser window is made narrow, the following code was used:

body {
    overflow: hidden;
}

span {
    border: solid 2px blue;
    white-space: nowrap;
    text-overflow: ellipsis;
}
Copy after login

However, this code is not producing the desired effect. To troubleshoot, it's important to ensure the following CSS properties are present:

  • Overflow: This property controls how content should flow outside of its container.
  • Width (or max-width): This property determines the maximum width of the span.
  • Display: This property specifies how the span should be displayed, typically set to inline, block, or inline-block.
  • White-space: This property dictates how white space is handled within the span.

Here's an example of a corrected code that includes these properties:

span {
    border: solid 2px blue;
    white-space: nowrap;
    text-overflow: ellipsis;
    width: 100px;
    display: block;
    overflow: hidden
}
Copy after login

By incorporating these CSS properties, the span should now shrink with ellipsis when the window becomes narrow.

The above is the detailed content of Why Isn't My `text-overflow: ellipsis` Working?. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template