Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 08-25-2003, 04:26 PM   #1
Member (6 bit)
 
Join Date: Apr 2003
Location: Phoenix, NY
Posts: 45
Send a message via AIM to Dickies8
smokin Centering a Background image with HTML?

i am trying to make a web page about me and some friends and i want to have pic that my g/f made to be the background but when i put it as the background it tiles and i want it right in the center of the page. i have tried a bunch of tags from different sites and nothing seems to work, am i missing something? here is some info that might help:

http://www.angelfire.com/theforce/redteamgo

^ (web page address)

Picture Information:

Name: background.jpg
Size: 797x480

i also have another one of the same pic but its dimensions are different, if someone could help me i would really appreciate it.
thanks!
Dickies8 is offline   Reply With Quote
Old 08-26-2003, 09:44 AM   #2
Member (7 bit)
 
chris1977uk's Avatar
 
Join Date: Sep 2002
Location: Middlesbrough, UK
Posts: 108
use a table, set it to 100% width and height, and use the image as the backgorund.

i think that will work!
chris1977uk is offline   Reply With Quote
Old 08-26-2003, 09:50 AM   #3
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
The easiest is to use a stylesheet like so:
PHP Code:
<style>
Body {
background-image url(/image_name);
background-repeat no-repeat;
background-position center;
}
</
style
Insert the style tags in the head section of your webpage and you are done.
mairving is offline   Reply With Quote
Old 08-26-2003, 10:51 AM   #4
Member (6 bit)
 
Join Date: Apr 2003
Location: Phoenix, NY
Posts: 45
Send a message via AIM to Dickies8
thank you ill give it a try and write back!
Dickies8 is offline   Reply With Quote
Old 08-26-2003, 03:31 PM   #5
I don't computer.
 
mjkovis's Avatar
 
Join Date: Mar 2003
Location: Ellisville, MO
Posts: 1,561
Quote:
Originally posted by mairving
The easiest is to use a stylesheet like so:
PHP Code:
<style>
Body {
background-image url(/image_name);
background-repeat no-repeat;
background-position center;
}
</
style
Insert the style tags in the head section of your webpage and you are done.
Goodness! That is new stuff from when I did some HTML script in high school on my own web pages. I always thought that you could just center the graphic with the simple command...
__________________
Gaming Rig -
ASUS A8N-SLi Deluxe :: AMD 64 X2 4600+ :: 3GB Corsair XMS PC-3200
ASUS GeForce GTX 560 (Fermi) 1GB :: SB Xi-Fi Fatal1ty Pro
500GB WD Black :: Sony DVD-ROM :: Plextor 716SA DVD/RW
OS - WinXP Pro :: Powered by - Enermax 535W PSU
ASUS G60JX Laptop -
Intel Core i5 M430 :: 4GB DDR3
NVIDIA GeForce GTS 360M 1GB :: 500GB SATA HD (7200)
OS - Win7 Home Premium 64-bit
mjkovis is offline   Reply With Quote
Old 08-26-2003, 04:02 PM   #6
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
Quote:
Originally posted by Acid-Klutch
Goodness! That is new stuff from when I did some HTML script in high school on my own web pages. I always thought that you could just center the graphic with the simple command...
You could center it horizontally but not vertically with the <center>. It would also not be a background image that other things could be placed on top of. You could also put it in the body tag but it would tile and not look so good.
mairving is offline   Reply With Quote
Old 08-26-2003, 04:05 PM   #7
I don't computer.
 
mjkovis's Avatar
 
Join Date: Mar 2003
Location: Ellisville, MO
Posts: 1,561
Quote:
Originally posted by mairving
You could center it horizontally but not vertically with the <center>. It would also not be a background image that other things could be placed on top of. You could also put it in the body tag but it would tile and not look so good.
That is right. Forgot about that. Been like 3 or 4 years since I fooled around with HTML script. I was pretty good for being 14 when I started. Ended it my senior year in high school cause I just wanted to have too much fun! hehe

I think I mainly used table formats though to center my images and place them where I wanted them.
mjkovis is offline   Reply With Quote
Old 08-26-2003, 04:12 PM   #8
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
Quote:
Originally posted by Acid-Klutch
That is right. Forgot about that. Been like 3 or 4 years since I fooled around with HTML script. I was pretty good for being 14 when I started. Ended it my senior year in high school cause I just wanted to have too much fun! hehe

I think I mainly used table formats though to center my images and place them where I wanted them.
And you still could use table formats or combine it with CSS.
mairving is offline   Reply With Quote
Old 08-26-2003, 05:07 PM   #9
Member (6 bit)
 
Join Date: Apr 2003
Location: Phoenix, NY
Posts: 45
Send a message via AIM to Dickies8
i tried your suggestions, but it still tiles, i dont know how to use tables and such, if anyone would be as kind to post the code for a table that would center the image on the page so i could copy and paste it, i would be truley grateful..=)
Dickies8 is offline   Reply With Quote
Old 08-27-2003, 03:34 AM   #10
Member (7 bit)
 
chris1977uk's Avatar
 
Join Date: Sep 2002
Location: Middlesbrough, UK
Posts: 108
< table height="100%" width="100%" background="imagepath.jpg" border="0" >

< tr >
< td >
< body of page >
< /td >
< /tr >
< /table >

i think!!!
chris1977uk is offline   Reply With Quote
Old 08-27-2003, 06:49 AM   #11
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
Quote:
Originally posted by Dickies8
i tried your suggestions, but it still tiles, i dont know how to use tables and such, if anyone would be as kind to post the code for a table that would center the image on the page so i could copy and paste it, i would be truley grateful..=)
Look here is an example that works. You may have to use the full path of your image.
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<
html>
<
head>
    <
title>Test Page</title>
    
    <
style>
Body {
background-image url(http://www.m2hosts.com/images/m2hosts_com.gif);
background-repeat no-repeat;
background-position center;
}
</
style>
    
</
head>

<
body>



</
body>
</
html
Here is what it actually looks like.

Last edited by mairving; 08-27-2003 at 06:52 AM.
mairving is offline   Reply With Quote
Old 08-27-2003, 03:14 PM   #12
Member (6 bit)
 
Join Date: Apr 2003
Location: Phoenix, NY
Posts: 45
Send a message via AIM to Dickies8
ill give it a try
thank you
Dickies8 is offline   Reply With Quote
Old 08-27-2003, 03:30 PM   #13
Member (6 bit)
 
Join Date: Apr 2003
Location: Phoenix, NY
Posts: 45
Send a message via AIM to Dickies8
it works! i really freakin works! this forum is the shiznit! thanks guys for all the help!
Dickies8 is offline   Reply With Quote
Old 08-27-2003, 09:51 PM   #14
Member (6 bit)
 
Join Date: Apr 2003
Location: Phoenix, NY
Posts: 45
Send a message via AIM to Dickies8
ok i got the image where i want it but not its leaving a white border around the right side and a orange-ish boarder on the bottom...i dont know what to do
Dickies8 is offline   Reply With Quote
Old 08-28-2003, 03:29 AM   #15
Member (7 bit)
 
chris1977uk's Avatar
 
Join Date: Sep 2002
Location: Middlesbrough, UK
Posts: 108
total guess but try


background-border : 0;


in there as well !!!
chris1977uk is offline   Reply With Quote
Old 08-28-2003, 05:19 AM   #16
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
That's probably the image itself. Do you have something for us to look at.
mairving is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes 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 On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 08:05 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2