Web Hosting, Design, & Coding forum

General discussion

Locking a background image

by winyard / February 24, 2005 9:54 PM 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
You are posting a reply to: Locking a background image
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: 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.
Collapse -
Try this method
by MarkFlax Forum moderator / February 25, 2005 8:48 PM PST
Collapse -
Fixed properties...
by johnhighway-20437154072583586110149507896481 / March 10, 2005 11:37 PM PST

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>

Popular Forums
icon
Computer Newbies 10,686 discussions
icon
Computer Help 54,365 discussions
icon
Laptops 21,181 discussions
icon
Networking & Wireless 16,313 discussions
icon
Phones 17,137 discussions
icon
Security 31,287 discussions
icon
TVs & Home Theaters 22,101 discussions
icon
Windows 7 8,164 discussions
icon
Windows 10 2,657 discussions

FALL TV PREMIERES

Your favorite shows are back!

Don’t miss your dramas, sitcoms and reality shows. Find out when and where they’re airing!