samuel toh samuel toh - 4 months ago 7
jQuery Question

how to add dots (...) with the same width?

Demo and full code is like this : https://jsfiddle.net/oscar11/Ldrntc8x/1/

When I using :

nm = 'chelsea chelsea chelsea chelsea chelsea chelsea chelsea';


And :
nm = 'iiiii iiiii iiiii iiiii iiiii iiiii iiiii iiiii';


Its width is different

How to keep it the same width?

In some tutorials using css width, but I am confused implementing

Answer

You should use a monospace font then.

E.g., add font-family:"Menlo"; (the one Stack Overflow uses for code blocks :)

body{
  font-family: Menlo;
}
iiiii iiiii iiiii<br>
wkerh werce kjhvg