将字符限制为特定宽度 [英] Limiting Characters to a specfic width

查看:86
本文介绍了将字符限制为特定宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经遇到过几次这个问题.将字符串中的字符限制为特定数字我没有问题.但是,某些字符比其他字符长,因此它会换行或使我的DIV元素更宽,并且与我网站的其余部分不一致.

I have run into this problem a few times. I have no problem limiting characters in a string to a specific number. However, some characters are longer than others so it wraps to another line or makes my DIV element wider and not uniform with the rest of my website.

例如:

Literacy - Is it the Sa
Machu Picchu, Cuzco, Pe

包括空格在内的字符数(23)完全相同,但马丘比丘(Machu Pichu)字符在屏幕上的实际宽度更长.

are the exactly the same amount of characters (23) including spaces but the Machu Pichu one is longer in terms of the actual width on screen.

是否有任何方法可以使字符串的大小基于实际字符串的宽度(而不是字符数)?有人必须为此提出解决方案,对吗?

Is there any way to have a uniform size for a string that is based on the width of the actual string as opposed to the number of characters? Someone has had to have come up with a solution to this before right?

推荐答案

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆