General discussion

Locking a background image

Feb 24, 2005 9:54PM PST

Can anybody tell me the html code needed to lock a background image on a page, so that the image does not move when a user scrolls down the page.
I had this on my site previously but have forgotten the code that I used.

Discussion is locked

Follow
Reply to: Locking a background image
PLEASE NOTE: Do not post advertisements, offensive materials, profanity, or personal attacks. Please remember to be considerate of other members. If you are new to the CNET Forums, please read our CNET Forums FAQ. All submitted content is subject to our Terms of Use.
Reporting: Locking a background image
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Comments
- Collapse -
Try this method
Feb 25, 2005 8:48PM PST
- Collapse -
Fixed properties...

If you're using HTML without cascading style sheets, it would be:

<body background="directory_path/filename" properties="fixed">
.
.
.
</body>

Where "directory_path" is the relative path or URL where the image exists and "filename" is the name of the file.

If you're going to use external cascading style sheets,

body {
background-image: url(directory_path/filename);
background-attachment: fixed;
}

If you're using internal cascading stylesheets, you would have something like:

<style type="text/css">
<!--
body {
background-image: url(directory_path/filename);
background-attachment: fixed;
}
-->
</style>

or

<body style="background-image: url(directory_path/filename); background-attachment: fixed;">
.
.
.
</body>

CNET Forums

Forum Info