 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
seanie morris
Joined: 02 Jun 2005 Posts: 49 Location: Offaly, Ireland
|
Posted: Sun Feb 11, 2007 2:05 pm BG image properties but within a table cell (centre/untiled) |
|
|
|
As an example, if you take a quick look at this post:
http://www.htmlcodetutorial.com/help/ftopic7404.html&highlight=background+image
it defines the properties for fixing a background image on a page (centered and unrepeating). Butwhat about from within a table cell, wishing to apply a background image, I won't be using CSS, will I? I have tried various tags (bgrepeat and bgposition and variations of) within the appropriate line:
<td width="508" height="582" valign="top" background="images/Dezynaweb_insignia_mediumhu.gif" bgcolor="#FFFFFF">
but I don't think I've got the right ones, or the right syntax perhaps.
Can anyone help me?
Seanie. |
|
Pattons3rd

Joined: 28 Dec 2006 Posts: 1212 Location: Colorado
|
Posted: Sun Feb 11, 2007 2:40 pm |
|
|
|
You could very easily use CSS on this, just use td as the selector.
Last edited by Pattons3rd on Fri Mar 23, 2007 5:35 pm; edited 1 time in total |
|
seanie morris
Joined: 02 Jun 2005 Posts: 49 Location: Offaly, Ireland
|
Posted: Sun Feb 11, 2007 3:10 pm |
|
|
|
so do you mean adding the:
<style=text/css......>
stuff inside the cell properties? I tried it and no joy. That means I'm doing it wrong... |
|
seanie morris
Joined: 02 Jun 2005 Posts: 49 Location: Offaly, Ireland
|
Posted: Sun Feb 11, 2007 3:34 pm Sorted! |
|
|
|
Actually, I just answered my own query! The following works:
Add the following, unedited, into the <head> of the document:
<style type="text/css">
.mybgimage {
background-image: url(images/the_background_image.gif);
background-repeat: no-repeat;
}
</style>
REPLACE "images" with the folder name of the location of the image, and "the_background_image.gif" with the name of the background image.
In the cell to add the image to, the start of it (in the code view) starts with <td....>, for example:
<td width="300" height="180" (and other criteria...)...>
AFTER "<td" ENTER "class="mybgimage"" so that it will now look like this:
<td class="mybgimage" width="300" height="180" (and other criteria...)...>.
Sorted me out fine. |
|
seanie morris
Joined: 02 Jun 2005 Posts: 49 Location: Offaly, Ireland
|
Posted: Sun Feb 11, 2007 3:42 pm |
|
|
|
Oh, and to center it from both the top and left/right sides of your cell, add the line "background-position: center center;" to the head part:
<style type="text/css">
.mybgimage {
background-image: url(images/the_background_image.gif);
background-repeat: no-repeat;
background-position: center center;
}
</style>
Hope this helps future noobs in bgproperties!
Seanie. |
|
Corey Bryant Site Admin

Joined: 15 May 2004 Posts: 8267 Location: Castle Rock CO USA
|
Posted: Mon Feb 12, 2007 3:41 am Re: BG image properties but within a table cell (centre/unti |
|
|
|
| seanie morris wrote: |
| Butwhat about from within a table cell, wishing to apply a background image, I won't be using CSS, will I? |
As you have seen, yes - you will be using CSS. CSS should be uses to apply background to all tags now - from background, divs, tables, tds, etc.
The background attribute in HTML has been deprecated in the newer versions of HTML.
_________________
Corey
Toll Free Fax Numbers | Merchant Accounts | Microsoft Expressions |
|
cyberience
Joined: 03 Sep 2008 Posts: 1
|
Posted: Wed Sep 03, 2008 6:55 pm The Real solution |
|
|
|
So many people beat around the bush with a narrow thinking process.
I can see what you want, I will tell you simply.
That is the wrong way to do it within the confines of the purpose of CSS, but alas, there is a solution.
Unknown to many, you can embed CSS in any tag within HTML.
For example.
<p style="background: blue; color: white;">A new background and font color with inline CSS</p>
So to solve your dilemma. which is probably solved now anyway this is the solution...
<table style="background-image: url(background.jpg); background-repeat: no-repeat; background-position: center center;"> .......blah blah blah.
But, most people will tell you, this is defeating the purpose of CSS, where you can separate the styling from the html code.
but to me, this flexibility allows you to customise portions of a page, and I always use templates for me development, and prefer to keep all the formatting in 1 file, so whether it is in a css section,or embedded within the tags, is really up to your style and way of keeping track.
A good programmer can read code and work it out, and average programmer can only follow standards, and a bad programmer can make the best standards in the work completely unreadable! |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
|