CSS Property Value How to - background-attachment: fixed;








Question

We would like to know how to background-attachment: fixed;.

Answer


<html>
<head>
<style>
body {<!-- w  ww.j a va  2  s .  co m-->
  background-image: url("http://java2s.com/style/download.png");
  background-attachment: fixed; 
  background-position: center;
  background-repeat: no-repeat;
  background-color: #eaeaea; 
}
</style>
</head>
<body>
    <p>This example illustrates the <b>background-attachment</b> property<p>
    <p>The<br />
    image<br />
    stays<br />
    in<br />
    the<br />
    same<br />
    place<br />
    even<br />
    when<br />
    you<br />
    scroll<br />
    down<br />
    the<br />
    page.</p>
</body>
</html>

The code above is rendered as follows: