Page 1 of 1

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

Posted: Thu Jun 19, 2008 8:28 am
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!

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

Posted: Thu Jun 19, 2008 9:05 am
by LibertyCabbage
You might need to dabble into CSS for that one.

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

Posted: Fri Jun 20, 2008 3:09 am
by Paul Escobar
CSS, huh? Too bad if that's the case - I haven't a clue how to use CSS...

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

Posted: Fri Jun 20, 2008 4:02 am
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...

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

Posted: Fri Jun 20, 2008 4:48 am
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

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

Posted: Mon Jun 23, 2008 11:06 am
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.

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

Posted: Mon Jun 23, 2008 2:58 pm
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. :)

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

Posted: Tue Jun 24, 2008 3:57 am
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

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

Posted: Wed Jun 25, 2008 12:47 am
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.