As we need to work on our own, we hope that the background layer of an image album will scroll, but the above layer will not scroll. Then we will find an example of scrolling Based on the jQuery background layer. we will share it with you below.
Jquery code
The Code is as follows: |
Copy code |
<Script type = "text/javascript" charset = "UTF-8"> Var scrollSpeed = 100; // speed (MS) Var step = 1; // move 1 pixel each time Var current = 0; // The current pixel row Var imageWidth = 2247; // The width of the scroll chart. Var headerWidth = 1280; // container width // Start of the loop Var restartPosition =-(imageWidth-headerWidth ); Function scrollBg (){ // Go to next pixel row. Current-= step; // If at the end of the image, then go to the top. If (current = restartPosition) {current = 0 ;} // Container IDClass Certificate ('{header'}.css ("background-position", current + "px 0 ");} // Repeated scrolling Var init = setInterval ("scrollBg ()", scrollSpeed ); </Script> |
The yellow color is the container ID or class. Put the above js near the background rolling container, and I have translated a few comments, there are a few more words out of my English scope, so I will not be moved.
Css code
The Code is as follows: |
Copy code |
# Header {height: 180px; background: # 8EC1DA url(bg-clouds.png) repeat-y scroll left top; text-align: center ;} |