Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trim a string Using css

Tags:

css

I want to Trim a string Using css . example my string is

"hi google how are you"

I Want to Get output

"hi"

Get first two letter . Using Css is it possible Trim a string .

like image 280
Biju s Avatar asked Jul 20 '26 11:07

Biju s


1 Answers

Although not possible using CSS; but you can get some kind of illusion in ideal condition may be this workaround work for you. I've used here text-overflow: ellipsis; you can check the DEMO.

<p>hi google how are you</p>

p {
    text-overflow: ellipsis;   /* IE, Safari (WebKit) */
    overflow:hidden;              /* don't show excess chars */
    white-space:nowrap;           /* force single line */
    width: 17px;  /*This property playing a major role just showing the first 2 letter*/
}
like image 185
Kheema Pandey Avatar answered Jul 22 '26 03:07

Kheema Pandey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!