DevelopPHP
home Forum gear home

Libraries book

HTML Library CSS Library JavaScript Library PHP Library

Videosbook

PHP and MySQL JavaScript HTML and CSS Vector and 3D Flash Actionscript Android Dev Miscellaneous

Resourcesbook

Website Hosting
CSS background-attachment example   Share / Like

The CSS background-attachment property is used to set backgrounds to be fixed in place, or to be scrolled with content.

CSS CODE EXAMPLE
<style type="text/css">
#myDiv {
    background-image: url(myBG.jpg);
    background-attachment: local;
    width:300px;
    height:100px;
    overflow:auto;
}
</style>
<div id="myDiv">
  <p>Content ...</p>
  <p>Content ...</p>
  <p>Content ...</p>
  <p>Content ...</p>
  <p>Content ...</p>
  <p>Content ...</p>
</div>
 

Content ...

Content ...

Content ...

Content ...

Content ...

Content ...

Possible Values:

fixed
Fix a background image to the viewport of an HTML element so it does not move.

scroll
Make an HTML element's background image scroll along with the element as it moves.

local
Use to make your background image scroll with the content inside elements. There must be enough content in your container to make scroll bars appear to see this effect.

 

Related Examples and Pages:

Create whole page backgrounds for your web documents

Home   •   Terms of Use   •   Developer Forums   •   T-Shirts   •   RSS   •   Classroom Chalkboard   •   Donate   •   Top ↑
Popular In PHP / MySQL E-Commerce Store Production
Social Network Website Building
Image Upload / Photo Processing
CMS Software Programming
Mass Email Systems
Magic XML Data
Search Programming
Popular In JavaScript JSON Programming
Ajax Programming
Animating Elements
WYSIWYG Programming
Date/Time Programming
DOM Scripting
Object Reference
Popular In HTML Canvas Element
New Form Elements
Audio Element
Video Element
Drag and Drop
Event Handling
Element Grouping
Popular In CSS Custom Font Embedding
Dynamic Fit Backgrounds
Theatre Mode
Box Overlays
CSS Level 1 Properties
CSS Level 2 Properties
CSS Level 3 Properties
©2013 DevelopPHP   |   Navigate to related domains HTML5