Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-24-2010, 09:46 AM   PM User | #1
akrylic
New Coder

 
Join Date: Oct 2010
Posts: 12
Thanks: 0
Thanked 3 Times in 3 Posts
akrylic is an unknown quantity at this point
Question JS Resize text like an image

Hi,
I was wondering how to resize a div containing some text by setting a width and height so it would stretch to fill that area like an <img> tag? E.g. when you set the width and height attribute of an image, it resizes the image to fill that area. I do not wish to send a request to a php script to build an image containing the text since it will be slow and affect the scalability of the web app. Oh, and I would preferably not like to use html5 because it is a requisite that I need compatibility with ie7+ (and firefox/chrome).

Thanks,
akrylic
akrylic is offline   Reply With Quote
Old 10-24-2010, 09:55 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,043
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Have a look at:-

http://www.dynamicdrive.com/dynamici...extresizer.htm


It is your responsibility to die() if necessary….. - PHP Manual
Philip M is offline   Reply With Quote
Old 10-24-2010, 10:55 AM   PM User | #3
akrylic
New Coder

 
Join Date: Oct 2010
Posts: 12
Thanks: 0
Thanked 3 Times in 3 Posts
akrylic is an unknown quantity at this point
Hi,
That looks interesting but I need to be able to specify an arbitrary width and height and have the text "stretched" to fill that space, so that is not quite what I'm looking for.
akrylic is offline   Reply With Quote
Old 10-24-2010, 01:45 PM   PM User | #4
siberia-man
Regular Coder

 
Join Date: Sep 2010
Location: Far far away
Posts: 122
Thanks: 0
Thanked 16 Times in 16 Posts
siberia-man is on a distinguished road
Quote:
Originally Posted by akrylic View Post
... how to resize a div containing some text by setting a width and height ...
Thinking that all you need is modify width or height properties of an element:
Code:
var el = document.getElementById(...);
el.style.width = ... + 'px';
el.style.height = ... + 'px';
siberia-man is offline   Reply With Quote
Old 10-24-2010, 02:08 PM   PM User | #5
akrylic
New Coder

 
Join Date: Oct 2010
Posts: 12
Thanks: 0
Thanked 3 Times in 3 Posts
akrylic is an unknown quantity at this point
This will resize the div itself, but the text will stay the same size. I need to stretch the text (even if it ends up looking horrible) to fit some dimensions. If you have an image that is say 600 by 400 pixels and have an img tag with a width of 100px and a height of 100px, then the image is stretched to fit the 100x100px position that is provided.
akrylic is offline   Reply With Quote
Old 10-24-2010, 02:46 PM   PM User | #6
siberia-man
Regular Coder

 
Join Date: Sep 2010
Location: Far far away
Posts: 122
Thanks: 0
Thanked 16 Times in 16 Posts
siberia-man is on a distinguished road
el.style.fontSize
siberia-man is offline   Reply With Quote
Reply

Bookmarks

Tags
div, img, resize

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 04:08 AM.


Advertisement
Log in to turn off these ads.