By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,723 Members | 1,662 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,723 IT Pros & Developers. It's quick & easy.

Question

P: n/a
hi, i am running some experiments and want to stretch an image behind a
table <tdcell. I don't care if it distorts, but thought maybe
Javascript was up my alley to start. Can someone pls help me with this
idea? :-)

Jan 24 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
al*****@gmail.com wrote:
hi, i am running some experiments and want to stretch an image behind a
table <tdcell. I don't care if it distorts, but thought maybe
Javascript was up my alley to start. Can someone pls help me with this
idea? :-)
alkalsa,

When you say 'behind' I deduce that you want to set the background of
the table cell. CSS 2 allows you to do this, thus:

background-image: url("something.jpg")

but does not provide a method to stretch the image to fill the cell. If
the cell is smaller than the image, only a portion of the image will
appear. If the cell is larger than the image, either:
- the image will appear once and the rest of the cell will not be
filled (or will be filled with the background-color, which you should
always specify in case the image cannot be displayed)
- the image will appear multiple times (tiled) in either the
horizontal direction, the vertical direction, or both, which you get to
choose via:

background-repeat: no-repeat (or repeat-x or repeat-y or just
repeat, which does both)

If your image is, for example, a piece of textured cloth, repeating it
in both directions may provide the effect you want.

See http://www.w3.org/TR/CSS21/colors.ht...def-background for more
detail on current capabilities.

CSS 3 appears to have anticipated your requirement. See
http://www.w3.org/TR/2005/WD-css3-ba...ackground-size,
especially Example 1. Note, however, that this is a working draft and
represents hope for the future, not something you can reliably use today.

I do not know how to do this with JavaScript. I suspect it would not be
trivial. Others may know better.

Some users do not enable JavaScript. If you use it, you should ensure
that your site still functions without it.

Chris Beall
Jan 24 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.