Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble getting a background inside a table... 2

Status
Not open for further replies.

UncleMortis

Programmer
Jan 28, 2003
120
AU
I'm trying to make a table that has a background texture to it, which is different to the background that runs in the main browser. I cannot for the life of me get it to show up. In my css file, I've included a class for it, but I get nothing. I've gone through all my table information in my books, I've gone through adding background images in my css book, I can't seem to find anything to work. What am I doing wrong? There's something missing but I can't put my finger on it. Below is an except of the code from my main html page and the external css file that links to it.

bit from css file...
Code:
.paper {background-image: url (paper.jpg);
             background-repeat: repeat;
             background-attachment: fixed;
              }
bit from main html page
Code:
<table border=1>
<tr>
<td class=paper>
Hope this works
</td>
</tr>
</table>

Is it something stupid I'm missing? I can add a normal colour background fine, When I went to add the jpg background, I realised I'd never done it before, but would think it's basically the same proceedure for adding a background to a normal page using css. The picture I want to use is in the right place and I know it works as an <img>. Any suggestions would save me from gray hair and a nervous disposition.
 
Worked for me ok.

Since you only have a small amount of text in your table, the size of the table will also be pretty small. Have you tried making your table bigger (height=400 width=400) to see if the image is actually being displayed in the background. You might find that any light color at the top of your image (assuming the top is fairly light), is only being shown.

Also try viewing the JPG in a browser, to see if it has been correctly saved (and not corrupt).

Hope this helps.

Pete.


Web Developer & Aptrix / IBM Lotus Workplace Web Content Management (LWWCM) Specialist
w: e: Pete.Raleigh(at)lclimited.co.uk
 
I think you need to make sure your page and your url image are in the same folder. Also, if you are just testing out this page and haven't saved it to a folder, that may be why you aren't getting what you expect.

Paul
 
That may be the problem then, not having the table big enough... As I said earlier, I tried it as an img src and it worked fine in the table, but I haven't tried with more text, I just put the text in there so I knew where the table was etc. I'll give that a go and see how it goes. My page and pic are also in the same folder, so I know it's going to work in that regard. Thanks guys.
 
I'm not sure if you've sent exactly the code you used for your style, but if so you have to take the space away between url (paper.jpg) should be url(paper.jpg) Hope this helps

Glen
 
Yes, got it working,Thanks glenmac, seems like it was the space between the url and the (paper.jpg). What I can't understand is how I managed to miss it with so many reruns of fixing it, I had so many different versions of what I posted, I'm surprised I didn't take the space out for one of them. It's always the small things with html and css isn't it. Thanks for your help guys as always.

 
Just tried the original code I played with, and yes, the space after the "url" IS important - don't have one! :)

Good spot glenmac.

Pete.


Web Developer & Aptrix / IBM Lotus Workplace Web Content Management (LWWCM) Specialist
w: e: Pete.Raleigh(at)lclimited.co.uk
 
Nice tip, Glen!

I just looked at the W3C standard, and, although it lets you have optional whitespace inside the brackets (and optional single or double quotes, too), there should be no space between url and opening bracket:


W3C said:
The format of a URI value is 'url(' followed by optional whitespace followed by an optional single quote (') or double quote (") character followed by the URI itself, followed by an optional single quote (') or double quote (") character followed by optional whitespace followed by ')'. The two quote characters must be the same.

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top