# background-attachment:fixed 问题

The value fixed stops the background-image from scrolling with its containing block. Note that although the fixed background-image may be applied to elements throughout the document, its background-position is always placed in relation to the viewport. This means the background-image is only visible when its background-position coincides with the content, padding, or border area of the element to which it is applied. Thus, a fixed background-image doesn’t move with elements that have a scrollbar—see overflow—because it’s placed in relation to the viewport.

<html>
<style type="text/css">
.hi
{
height:200px;
width:200px;
border:1px solid blue;
background-image:url('eg_bg_03.gif');
background-repeat:no-repeat;
background-attachment:fixed;
background-position:left top;
}

</style>

<body>
<body>
<div style="height: 500px;">i</div>
<div class="hi">
zheli
</div>
</body>
</html>

Total views.

Powered by Hydejack v6.6.1