HTML help, please: Setting a background image? [solved]

For requests for help from CG administrators, Wranglers, and experienced CG members. Please read the FAQ before posting. Also look at CG Wiki for tutorials and how-tos written by other CG webtoonists.
Post Reply
User avatar
Paul Escobar
Cartoon Hero
Posts: 1024
Joined: Wed Nov 30, 2005 2:11 pm
Location: State of Flux

HTML help, please: Setting a background image? [solved]

Post by Paul Escobar »

I'd like to have a background image on the index page of my site. I've tried adding this:

Code: Select all

<body background="[image]" style="background-repeat: no-repeat" bgcolor="#ffffff">
to the index.html file, and voilà, there's the background image. So far so good. However, it's aligned top left, and I'd like it aligned center. Which I can't figure out how to do. When I add:

Code: Select all

<body background="[image]" style="background-align: center; background-repeat: no-repeat" bgcolor="#ffffff">
or anything of the sort, the image stubbornly remains aligned top left. I don't get it. I've googled for info, but found fuckall on this particular subject.

So. Can anyone tell me what code I need to make a background image center aligned? Pretty please with sugar on top.

Edit: Solved!
Last edited by Paul Escobar on Fri Jun 20, 2008 4:50 am, edited 1 time in total.

User avatar
LibertyCabbage
Cartoon Hero
Posts: 4667
Joined: Tue Jan 25, 2005 4:08 pm
Location: bat country
Contact:

Re: HTML help, please: Setting a background image?

Post by LibertyCabbage »

You might need to dabble into CSS for that one.
ImageImage
"Seems like the only comics that would be good to this person are super action crazy lines, mega poses!"

User avatar
Paul Escobar
Cartoon Hero
Posts: 1024
Joined: Wed Nov 30, 2005 2:11 pm
Location: State of Flux

Re: HTML help, please: Setting a background image?

Post by Paul Escobar »

CSS, huh? Too bad if that's the case - I haven't a clue how to use CSS...

User avatar
Dr Neo Lao
Cartoon Hero
Posts: 2397
Joined: Wed Oct 18, 2006 5:21 am
Location: Australia

Re: HTML help, please: Setting a background image?

Post by Dr Neo Lao »

Add this inside the head of your template(s):

Code: Select all

<style type="text/css">
body { background-image: url('/images/filename.jpg');  background-position: center; background-repeat: no-repeat; }
</style>
And replace filename with the name of the background image. Do not put any information about the background in the < body > tag.

That ought to work, but my memory might be off...

User avatar
Paul Escobar
Cartoon Hero
Posts: 1024
Joined: Wed Nov 30, 2005 2:11 pm
Location: State of Flux

Re: HTML help, please: Setting a background image?

Post by Paul Escobar »

I couldn't get that to work - don't know why. But it solved the problem indirectly: When I write "background-position" instead of "background-align" in the <body> tag - the image is center aligned! Whee! Odd really, since "align" works for everything else. So I wouldn't have thought of that option if I hadn't seen it in your code. Thank you! :D

User avatar
Jesusabdullah
Cartoon Hero
Posts: 1993
Joined: Thu Apr 28, 2005 6:11 pm
Location: The Frigid Northern Wastes.
Contact:

Re: HTML help, please: Setting a background image? [solved]

Post by Jesusabdullah »

I know the promblem was solved and stuff, but...

I've said it before, and I'll say it again: css is really slick. It's worth learning at least enough to bullshit your way through it, I think.

User avatar
Paul Escobar
Cartoon Hero
Posts: 1024
Joined: Wed Nov 30, 2005 2:11 pm
Location: State of Flux

Re: HTML help, please: Setting a background image? [solved]

Post by Paul Escobar »

I've heard many people recommend CSS as very useful, and in principle I agree that it would be good to learn CSS and PHP and other such neat site-building stuff.

It's just that my site isn't a big, ambitious thing; it's simply a place where I display a few visual brainfarts and silly short comics. I'm therefore disinclined to invest overly much effort in the technical side of it. Learning HTML was effort enough! If I can make it work and look not ugly, then I'm satisfied, really. [/lazy bastard]

But thanks for the thought. A lot of people would probably do well learning CSS. :)

User avatar
Dr Neo Lao
Cartoon Hero
Posts: 2397
Joined: Wed Oct 18, 2006 5:21 am
Location: Australia

Re: HTML help, please: Setting a background image? [solved]

Post by Dr Neo Lao »

Actually, you can safely ignore php since CG does not support it (unless you have your own hosted site elsewhere).

CSS is quite snazzy and you don't really need to learn it - just cheat and get others to show you the little bits to make your site snazzy and stop there... :D

User avatar
C.w.
Regular Poster
Posts: 343
Joined: Wed Apr 05, 2006 10:04 pm
Contact:

Re: HTML help, please: Setting a background image? [solved]

Post by C.w. »

Seriously, you almost already know CSS.

Code: Select all

style="background-position: center; background-repeat: no-repeat"
That IS CSS. The only difference is that instead of saying you wanted to do it to the body tag like so:

Code: Select all

body {
background-image: url('/images/filename.jpg');
background-position: center;
background-repeat: no-repeat; }
you just put it inside the body tag.
Image
Other comics i've done
Webpage troubles? HTML Generator to the rescue.

Post Reply