[SOLVED] background img center in table

This is a discussion on "[SOLVED] background img center in table" within the Web Page Design section. This forum, and the thread "[SOLVED] background img center in table are both part of the Design Your Website category.



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

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 28th, 2007, 06:28
New Member
Join Date: Sep 2007
Location: rva
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] background img center in table

Hi, i have a background image for a table on my site. I would like for the background image to stay centered, but it remains aligned left.

here is the code for it:

table bgcolor="#000000" background="../images/bg/bg5.jpg" width="100%" height=100%" border="0" cellspacing="0" cellpadding=0"


How do I align this background image center?

thanks

L

  #2 (permalink)  
Old Sep 28th, 2007, 08:07
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: background img center in table

It is more easier doing it in CSS.

Isn't this code will fill the entire table with repeating image?

Code: Select all
<table bgcolor="#000000"  background="../images/bg/bg5.jpg" width="100%" height=100%" border="0" cellspacing="0" cellpadding=0">
or do you mean like this:

Code: Select all
<table style="width: 100%" cellpadding="4" cellspacing="6">
  <tr>
     <td style="text-align: center">
        <img src="../images/bg/bg5.jpg" width="850" height="439" />
     </td>
  </tr>
</table>
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)

Last edited by Monie; Sep 28th, 2007 at 08:23.
  #3 (permalink)  
Old Sep 28th, 2007, 15:09
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: background img center in table

I'm confused with what you are wanting to do. I think that you want your bg image to be centered, but the table to be aligned left?

I can't think of a html way. CSS would be the obvious choice and I'm still a little hesitant, I never use tables for layout, but I think this may be the required code:

Edit: Ok, I have a way. It's gonna require a bit more CSS and I'm not sure if this is the quickest or easiest way, but it does work.

Code: Select all
<head>
<style type="text/css">
.tablewrapper {
background-position: center;
background-image: url(logo1.jpg);
height: 800px;
width: 600px;
background-repeat: no-repeat;
}

</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<div class="tablewrapper">
<table width=600 height="800" cellpadding="2" border="1px solid black">
<tr><td>blah</td><td>blah</td><td>blah</td><td>blah</td></tr>
<tr><td>blah</td><td>blah</td><td>blah</td><td>blah</td></tr>
<tr><td>blah</td><td>blah</td><td>blah</td><td>blah</td></tr>
<tr><td>blah</td><td>blah</td><td>blah</td><td>blah</td></tr>
</table></div>
</body>
However, it does depend on the image. If it is a logo, you will need to make the image the same size as the table and edit the width and height of the table and the css, if your image is say, a blue and black striped bg, you can set it to repeat-y and it should repeat.

That worked for me.

Hopefully I have helped a bit.

Jack
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)

Last edited by Jack Franklin; Sep 28th, 2007 at 15:19.
  #4 (permalink)  
Old Sep 28th, 2007, 19:56
New Member
Join Date: Sep 2007
Location: rva
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Re: background img center in table

Tried the above, maybe I'm not getting it. I think seeing the page will explain it better.

I have a table enclosing the entire page, so the whole page is a td basically. I am trying to make the table background an image that repeats down, but i need it to be the table background since that is what takes up the space.

here is the page, i'm sure that i am doing a terrible job explaining things.

http://kitchentablelegs.com/printing/index.html

the background currently is the bg of the outermost table, and it repeats of it's own accord. my problem is that I need it to be centered so that it is even on both sides of my main site/area.

sorry if im terribly confusing, or going about this in a terrible way. thanks for your help
  #5 (permalink)  
Old Sep 28th, 2007, 21:13
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: background img center in table

Hmm. I thought I understood until I looked at the site. Now I have no idea! You want a background image in the td to run down the page and repeat, but it needs to be centered? From what I can see on your web page, it is.

This should work.
Code: Select all
.tdwithimage {
background-image: image.jpg;
background-position: center;
background-repeat: repeat-y;
}
 
<td class="tdwithimage">~all your stuff here~</td>
Sorry I can't be of more help - I'll keep trying though!

Jack

Yes? No?
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
  #6 (permalink)  
Old Sep 28th, 2007, 21:22
New Member
Join Date: Sep 2007
Location: rva
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Re: background img center in table

Tried that but it didn't get it. I think I need the bg image to be for the entire table, not the td.
  #7 (permalink)  
Old Sep 28th, 2007, 21:24
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: background img center in table

Well then apply the above class to the <table> tag.

You know the CSS must go in the <head> section or an external style sheet?

(Just checking :P)

I'm sure we shall get there eventually!

Jack
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
  #8 (permalink)  
Old Sep 29th, 2007, 01:55
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: background img center in table

Quote:
Originally Posted by robertl View Post
Tried that but it didn't get it. I think I need the bg image to be for the entire table, not the td.
Yeah,

I discover the problem man!
It's not your CSS, Its your image "bg5.jpg" width setting!

Check out what's your background image doing when I throw away the table on top of it!
I think you have to set the table width according to your image width so it fits perfectly inside the table width, otherwise, it will repeat, or if you turn off the repeat x or y, you'll get the background image to be at the left of your table (default value)

Hope that helps!
Attached Images
File Type: jpg background.jpg (46.0 KB, 18 views)
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
  #9 (permalink)  
Old Sep 29th, 2007, 17:33
New Member
Join Date: Sep 2007
Location: rva
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Re: background img center in table

hell yeah! thank you, now i can finally move onto some other problem..
  #10 (permalink)  
Old Oct 1st, 2007, 05:27
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: background img center in table

No problem! Good luck with your site..
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Closed Thread

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
Align <li> in center? SOLVED Jack Franklin Web Page Design 4 Feb 18th, 2008 20:14
background image table properties geyids Web Page Design 3 Apr 18th, 2007 20:23
How to center a page without use of a table pdk Web Page Design 23 Jan 31st, 2007 11:28
center align text/background image Lchad Web Page Design 5 Dec 5th, 2006 10:40
Center slice table vertically Legacy_Staff Web Page Design 9 May 5th, 2006 18:48


All times are GMT. The time now is 09:10.


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