Quackit Logo

10GB Webmaster Package

Unique, quality digital content ready to be resold.

Includes:

  • Over 29,000 Ebooks
  • Over 7,000 Website templates
  • Over 11,000 Fonts
  • Over 39,000 Logos
  • Over 1,000 Cell Phone Games
  • Over 3,000 Cell Phone Images
  • Over 21,000 Ring Tones
  • ...and much more!
Get your 10GB webmaster package now!

HTML Fixed Background

Print Version

This article provides HTML fixed background code - code for fixing the background image of an HTML element so that it doesn't scroll when its containing block scrolls.

To fix the position of a background image, use the CSS background-attachment property.

Example code:

<div style="background-image:url(/pix/smile.gif);
		background-repeat:repeat;
		background-attachment:fixed;
		overflow:scroll;
		width:200px;
		height:100px;">
</div>

This results in:

HTML fixed background code is generated by applying the CSS background-attachment property against an HTML element. When the box scrolls, the background image stays fixed in the same position.

Shorthand Code

You can use the CSS background tag to set all the background properties at once. Therefore, using the previous code example, we could rewrite it to this:

<div style="background:url(/pix/smile.gif) repeat fixed;
		overflow:scroll;
		width:200px;
		height:100px;">
HTML fixed background code is generated by applying the
CSS background-attachment property against an HTML element.
When the box scrolls, the background image stays fixed
in the same position.
</div>
HTML fixed background code is generated by applying the CSS background-attachment property against an HTML element. When the box scrolls, the background image stays fixed in the same position.

Enjoy this website?

  1. Link to this page (copy/paste into your own website or blog):
  2. Add this page to your favorite social bookmarks sites:
                     
  3. Add this page to your Favorites

Oh, and thank you for supporting Quackit!

FREE Hosting!

With every domain name you register with ZappyHost, you get FREE (ad supported) hosting.

PLUS you get:

  • FREE Website Builder
  • FREE Blog
  • FREE Starter Web Page
  • FREE Email Account
  • & much more! (Total value $123 for FREE!)
Get your FREE hosting today! >>