This is a discussion on "Randomly generated one line text filling out the width of a div?" within the Web Page Design section. This forum, and the thread "Randomly generated one line text filling out the width of a div? are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Randomly generated one line text filling out the width of a div?
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Let's say I have a div with the width 830px and 2 to 5 random words in it, what I want is to have the first and the last word touching the ends of the div no matter how many or what words are in the div, and more or less the same spaceing between each word.
Examples ("-" stands for spaces or margin/padding pixels): Example1: Random--------Foo--------Bar---------Tips Example2: Testing----------------------------------This Example3: Notes--------------Goo---------------Words Example4: Name Here---------Images---------Videos There is no way for me to know what words will enter the div, this must happen automatically, I can't manually add spaces( ). Is this possible using XHTML and CSS? I think this is basically what justify/justifying does, but so far I haven't managed to get it working for one line only, and I need sometimes to make two words or more behave like one entity (one spaces between words) like in example 4 where "Name Here" has only one space. Last edited by brynjarh; Mar 11th, 2008 at 18:27. |
|
|
|
||||
|
Re: Randomly generated one line text filling out the width of a div?
The more I think about it, the harder it seems!
I'm not sure this is possible using static CSS and xHTML. In other words, you would need to code a script that outputs dynamic CSS and/or xHTML, based on the word size and quantity. Perhaps something that wraps each word in a <span>, then assign margins/padding based on the number of <span>'s there are.
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
|
|
||||
|
Re: Randomly generated one line text filling out the width of a div?
there is word-spacing: in CSS 2 etc.. Anything that does this easily is CSS3 such as text-justify:newspaper; which would do what you need only its not supported yet. Best solution may be to just created a floated div for each word, have that div space accordingly. perhaps using #foo:first-child {} and #foo:last-child {} to handle the first and last then a generic style on remaining elements.
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
|
||||
|
Re: Randomly generated one line text filling out the width of a div?
sometimes when i do use dw it does this horrible thing of justifying the last line of a paragraph, so it does fill the whole line. Perhaps speak to the ex mm staff to find out how to achieve it
Last Blog Entry: Fobriwap! (Mar 10th, 2008)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Have a major problem with Text Line-Height | vidoewebmastery | Web Page Design | 2 | Mar 24th, 2008 20:15 |
| Navigation menu randomly altering its appearance | servedchilled84 | Web Page Design | 1 | Jan 20th, 2008 00:02 |
| scroll does not line up text and background | cherishkiss | Web Page Design | 2 | Feb 22nd, 2007 15:40 |
| Text Alignment on second line of Bullet point | adeking | Web Page Design | 2 | Jul 31st, 2006 20:38 |
| text in one line - How To Avoid TABLE tag and use CSS ? | pugo | Web Page Design | 4 | Jan 18th, 2006 04:14 |