spacing to align lines..

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Drachlen
Forum Contributor
Posts: 153
Joined: Fri Apr 25, 2003 1:16 am

spacing to align lines..

Post by Drachlen »

You know how in books, or some news-posting systems on webpages, you'll see this double-spacing or sometimes triple-space inbetween words to align the end of lines? It aligns all the cols perfectly.. Well im curious as to how some php scripts do this... I've attempted to grab the string length of each line, and then add a space next to other spaces until the line is the length i set, but i am not able to just update 1 space. So has anyone done anything like this and like to shed some light? If i could figure out a way to limit str_replace to only 1 replace then i might be able to do it..
User avatar
SantaGhost
Forum Commoner
Posts: 41
Joined: Mon Sep 15, 2003 11:54 am

Post by SantaGhost »

i think your best guess on this is css (http://www.w3schools.com/css)
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Re: spacing to align lines..

Post by Heavy »

CSS:

Code: Select all

<div style="text-align:justify">This may be what you are looking for?This may be what you are looking for?This may be what you are looking for?This may be what you are looking for?This may be what you are looking for?This may be what you are looking for?This may be what you are looking for?This may be what you are looking for?This may be what you are looking for?</div>
Try that.
It is not PHP. This is all client side. In fact PHP can not deal with this, as the impression on the user is totally dependent on the font faces and font sizes that are used aswell as what browser renders the output.

I believe it is the style="text-align:justify" part you are interested of.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

You can also use wordwrap() to automaticly wrap strings after a certain num of chars.
Drachlen
Forum Contributor
Posts: 153
Joined: Fri Apr 25, 2003 1:16 am

Post by Drachlen »

Thanks heavy :D
Post Reply