Jump to content

Recommended Posts

How can you make it so if your text surpasses the space allowed... it will cut it and add the usual three dots... like "I went to six flags today and it..." limiting the characters doesn't work cuz if 20 W's can fill the space... you shouldn't limit it to 20 cuz 20 a's would only take half the space and it would look awkward if you know what im getting at... is there a standard way of doing this? Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/208110-space-limit/
Share on other sites

So basically there is only one way to completely make sure your text limit fits the space provided perfectly... and that is combining a mono space font with a max character limit... right? if that is right that sucks for the fact that you're limited to a few mono space type fonts....

Link to comment
https://forums.phpfreaks.com/topic/208110-space-limit/#findComment-1087973
Share on other sites

No, even that won't work. The user can change the font size the browser uses. The real answer is there is no reliable way to do what you that. You can try to force the font size using CSS, but that can be overridden too.

Link to comment
https://forums.phpfreaks.com/topic/208110-space-limit/#findComment-1087985
Share on other sites

I just want to make it so if a user DOESN'T force the browser to display the text in a different way... the text will fix the 245x41 div box... i use arial font and i like it and limiting the amount of text allowed by characters isn't good enough cuz arial isn't a monospace font which means w isn't the same width as W or a... etc.... any ideas??

Link to comment
https://forums.phpfreaks.com/topic/208110-space-limit/#findComment-1087994
Share on other sites

If you're determined to use a non-fixed-width font, figure out which is the widest character, and limit it to the maximum number of them that will fit. That's about the best advice i can think of at the moment.

Link to comment
https://forums.phpfreaks.com/topic/208110-space-limit/#findComment-1087999
Share on other sites

Why dont you make 2 div boxes..

 

One is the text string

Two is ...

 

Then put the Z-index of the ... string above the text string

 

So your Div / cell would look like=

 

I went to six flags today and it was a fun time

 

then place your ... at a certain location .. say right 100 pixels and place that on top of your text string div

 

so now it will be

 

I went to six flags t[...                                                                      ]

 

and following lines would look the same

 

I went to six flags t[...   

WWWWWWWWWV[...

aaaaaaaaaaaaaaa[...

 

except perfectly aligned since you are placing the ... div X amount of pixles from the left or right. The rest of the ... div would be the same color as your background so you couldnt tell it was actually a layer hovering over the text.

Link to comment
https://forums.phpfreaks.com/topic/208110-space-limit/#findComment-1088001
Share on other sites

i use arial font and i like it

 

But you have no (or very little) control over what typeface the browser will use. If the user does not have Arial on their machine installed, then an entirely different font may be used.

 

I understand this, but that is their problem... I'm making it work for people who use Firefox, and have Arial font installed on their system.

Link to comment
https://forums.phpfreaks.com/topic/208110-space-limit/#findComment-1088246
Share on other sites

In that case, I reiterate:

 

If you're determined to use a non-fixed-width font, figure out which is the widest character, and limit it to the maximum number of them that will fit. That's about the best advice i can think of at the moment.

 

The function you'll need is wordwrap().

Link to comment
https://forums.phpfreaks.com/topic/208110-space-limit/#findComment-1088252
Share on other sites

xcandiottix, thats a good idea but what if it doesn't surpass the allowed space and doesn't need the ... then its gona be their for no reason..

 

If(String length < 10 characters){

do no create ... div layer.}

else{

create div layer}

 

Now it's only there if it needs to be.

Link to comment
https://forums.phpfreaks.com/topic/208110-space-limit/#findComment-1088265
Share on other sites

nice idea man

The only thing that is going to be tricky is that if you set the DIV to appear at say 20 pixels ... lets look how letters might be chopped:

 

.................... <- "20 pixels"

WWWWWWW

aaaaaaaaaa

QQQQQQQQQ

LLLLLLLLLLLL

 

The very left part of the 7th W might still be visible. a and Q should be hidden nicely ... the last L might have part of it's leg cut off. But again, this will vary WIDELY from browser to browser. I would try it out and if it leaves parts of letters or cuts letters you might just have to accept it as on my browser it may look fine. But atleast you'll have an exact pixel cut off for each string.

Link to comment
https://forums.phpfreaks.com/topic/208110-space-limit/#findComment-1088269
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.