Randomly generated one line text filling out the width of a div?

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.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Mar 11th, 2008, 18:15
New Member
Join Date: Mar 2008
Location: Iceland
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question Randomly generated one line text filling out the width of a div?

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.
Reply With Quote

  #2 (permalink)  
Old Mar 11th, 2008, 21:32
Aso's Avatar
Aso Aso is offline
Chief Moderator

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 1,003
Blog Entries: 2
Thanks: 5
Thanked 23 Times in 20 Posts
Send a message via Skype™ to Aso
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)
Reply With Quote
  #3 (permalink)  
Old Mar 11th, 2008, 22:55
moojoo's Avatar
Moderator
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,738
Blog Entries: 1
Thanks: 0
Thanked 16 Times in 16 Posts
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
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.
__________________
The internet is just a fad.
http://www.mevans76.com
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Reply With Quote
  #4 (permalink)  
Old Mar 12th, 2008, 03:39
frinkky's Avatar
Design Admin
Join Date: Oct 2006
Location: Southampton
Age: 30
Posts: 270
Blog Entries: 2
Thanks: 2
Thanked 2 Times in 2 Posts
Send a message via MSN to frinkky Send a message via Skype™ to frinkky
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)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 19:30.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43