DEV Community

YURII DE.
YURII DE.

Posted on

5 3

CSS: Dynamically Text Truncate

DEMO: https://jsfiddle.net/bc6ep913/

PREVIEW

Image description

HTML

<div class="wrap">
  <div class="text-truncate">
    The glory and freedom of Ukraine has not yet perished
Luck will still smile on us brother-Ukrainians.
Our enemies will die, as the dew does in the sunshine,
and we, too, brothers, we'll live happily in our land.
  </div>
</div>
<div class="wrap">
  <div class="text-truncate">
    The glory and freedom of Ukraine has not yet perished
Luck will still smile on us brother-Ukrainians.
Our enemies will die, as the dew does in the sunshine,
and we, too, brothers, we'll live happily in our land.
  </div>
</div>
Enter fullscreen mode Exit fullscreen mode

CSS

.wrap {
  display: table;
  table-layout: fixed;
  width: 100%;
}

.text-truncate {
  display: table-cell;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
Enter fullscreen mode Exit fullscreen mode

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more