Edd
Edd

Reputation: 685

CSS cutting text and numbers

I have a large text "desoxyribonucleic" and number 0.4234 or 0.352352523

So I need such format of represent it:

text: desoxyribon... number: 0.42 number: 0.35

Is it real to roll out this with CSS? Thanx!

Upvotes: 2

Views: 333

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324780

Yup!

.ellipsis {
    max-width: 100px; /* adjust as needed */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* magic happens here */
}

For numbers, you can try using someNumber.toFixed(2) in JavaScript, just be careful of rounding.

Upvotes: 3

Related Questions