Forum Moderators: not2easy

Message Too Old, No Replies

How can I fix a background Image

         

Azza

4:04 am on Aug 3, 2004 (gmt 0)

10+ Year Member



I have just started learning to use CSS, and cant seem to fix my bg image.
The code I have written is;

<style type="text/css">
body { background: url(trowelman.gif); color: black; }

A:link { color: #000099 } /* unvisited links */
A:visited { color: #FF0033 } /* visited links */
A:hover { color: #0000FF } /* user hovers */
A:active { color: #00ff00 } /* active links */
font-size { size: 12px; }
p { text-indent: 2em: margin-top: 0; margin-bottom: 0; }
</style>

Is there a way to fix the bg image using css?

Cheers

D_Blackwell

7:16 am on Aug 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How do you mean fix? It should work. Is the path correct?

font-size { size: 12px; }

The property "font-size" needs to be in a declaration such as:
p {
font-size: 12px;
}

You could shorthand the colors: #f03 etc.

Azza

9:50 pm on Aug 3, 2004 (gmt 0)

10+ Year Member



<quote>How do you mean fix? It should work. Is the path correct?</quote>

Oh the BG image shows alright but it scrolls with the page and i want it to stay fixed firmly in the centre.
I would usually write it like;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.wc3.org/tr/html4/strict.dtd">
<html>
<head>
<title>you little ripper</title>
<body bgcolor="#ffffff" text="#003366" link="#0000CC" vlink="#006600" alink="#ff6666" topmargin="2" leftmargin="5" background="trowelman.gif" bgproperties="fixed">
</body>
</html>

But I want to use CSS so if I write this;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.wc3.org/tr/html4/strict.dtd">
<html>
<head>
<title>You little ripper</title>
<style type="text/css">
body { background: url(trowelman.gif); color: black; }

A:link { color: #009 } /* unvisited links */
A:visited { color: #F03 } /* visited links */
A:hover { color: #00F } /* user hovers */
A:active { color: #0f0 } /* active links */
p {
font-size: 12px;
}
p { text-indent: 1em; margin-top: 0; margin-bottom: 0; }
</style>
</head>
<body>
</body>
</html>

how do I stop the image scrolling?

<quote>The property "font-size" needs to be in a declaration such as:
p {
font-size: 12px;
}</quote>

Thanks for that. That was going to be my next question

<quote>You could shorthand the colors: #f03 etc.</quote>

Hey that is an awesome tip. Thanks very much for that

benihana

10:02 pm on Aug 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



add
background-attachment:fixed;

to the body selector in the css.

Azza

10:18 pm on Aug 3, 2004 (gmt 0)

10+ Year Member



Hey Thanks benihana

You are a true champion. That works a treat