background-attachment



значения свойства:


  • scroll
  • fixed
  • local



css/style.css
  • * {
  •  margin: 0;
  •  padding: 0;
  • }
  •  
  • .main {
  •  height: 600px;
  •  width: 900px;
  •  position: absolute;
  •  top: 50%;
  •  left: 50%;
  •  margin-top: -300px;
  •  margin-left: -450px;
  • }
  •  
  • .wrapper {
  •  width: 33.3%;
  •  height: 100%;
  •  float: left;
  • }
  •  
  • #div1, #div2, #div3 {
  •  height: 300px;
  •  width: 200px;
  •  float: left;
  •  position: relative;
  •  top: 50%;
  •  left: 50%;
  •  margin-top: -150px;
  •  margin-left: -100px;
  •  border: 1px solid #808080;
  •  background-image: url(../img/a.png);
  •  overflow-x: auto;
  •  background-repeat: no-repeat;
  • }
  •  
  • #div1 {
  •  background-attachment: fixed;
  • }
* {
 margin: 0;
 padding: 0;
}

.main {
 height: 600px;
 width: 900px;
 position: absolute;
 top: 50%;
 left: 50%;
 margin-top: -300px;
 margin-left: -450px;
}

.wrapper {
 width: 33.3%;
 height: 100%;
 float: left;
}

#div1, #div2, #div3 {
 height: 300px;
 width: 200px;
 float: left;
 position: relative;
 top: 50%;
 left: 50%;
 margin-top: -150px;
 margin-left: -100px;
 border: 1px solid #808080;
 background-image: url(../img/a.png);
 overflow-x: auto;
 background-repeat: no-repeat;
} 

#div1 {
 background-attachment: fixed;
}


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <link href="css/style.css" rel="stylesheet" />
  •  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  • </head>
  • <body>
  •  <div class="main">
  •   <div class="wrapper">
  •    <div id="div1">
  •     I was dreaming about Hawaii. I was dreaming about my holiday. In my dream, I was on the beach in Hawaii. The hot sun was shining on my face. The sound of the sea was all around me. But it was a dream. Three weeks ago, I had been lying on a beach in Hawaii. But I was not in Hawaii now. I was dreaming in my office in Los Angeles. I had returned from my holiday and there was no work for me. Nobody wanted to hire me. I went to my office every day, but the telephone didn't ring. So I slept in my chair and I dreamt about Hawaii. I was dreaming a wonderful dream. The sun was hot. The noise of the sea was loud and there was a beautiful woman standing next to me. Suddenly, there was a voice in my dream. Somebody was calling my name. 'Mr Samuel! Mr Samuel, wake up! Please, wake up! I want to talk to you.' I opened my eyes. It was April in Los Angeles. The hot sun was shining on my face. The sun was shining through my office window. And there was a woman standing beside me. She was calling my name. But she was angry with me. 'Mr Samuel. Wake up! Why are you sleeping at 11.45 in the morning?' The woman was about twenty-five years old. She had long dark hair.
  •    </div>
  •   </div>
  •   <div class="wrapper">
  •    <div id="div2">
  •     I was dreaming about Hawaii. I was dreaming about my holiday. In my dream, I was on the beach in Hawaii. The hot sun was shining on my face. The sound of the sea was all around me. But it was a dream. Three weeks ago, I had been lying on a beach in Hawaii. But I was not in Hawaii now. I was dreaming in my office in Los Angeles. I had returned from my holiday and there was no work for me. Nobody wanted to hire me. I went to my office every day, but the telephone didn't ring. So I slept in my chair and I dreamt about Hawaii. I was dreaming a wonderful dream. The sun was hot. The noise of the sea was loud and there was a beautiful woman standing next to me. Suddenly, there was a voice in my dream. Somebody was calling my name. 'Mr Samuel! Mr Samuel, wake up! Please, wake up! I want to talk to you.' I opened my eyes. It was April in Los Angeles. The hot sun was shining on my face. The sun was shining through my office window. And there was a woman standing beside me. She was calling my name. But she was angry with me. 'Mr Samuel. Wake up! Why are you sleeping at 11.45 in the morning?' The woman was about twenty-five years old. She had long dark hair.
  •    </div>
  •   </div>
  •   <div class="wrapper">
  •    <div id="div3">
  •     I was dreaming about Hawaii. I was dreaming about my holiday. In my dream, I was on the beach in Hawaii. The hot sun was shining on my face. The sound of the sea was all around me. But it was a dream. Three weeks ago, I had been lying on a beach in Hawaii. But I was not in Hawaii now. I was dreaming in my office in Los Angeles. I had returned from my holiday and there was no work for me. Nobody wanted to hire me. I went to my office every day, but the telephone didn't ring. So I slept in my chair and I dreamt about Hawaii. I was dreaming a wonderful dream. The sun was hot. The noise of the sea was loud and there was a beautiful woman standing next to me. Suddenly, there was a voice in my dream. Somebody was calling my name. 'Mr Samuel! Mr Samuel, wake up! Please, wake up! I want to talk to you.' I opened my eyes. It was April in Los Angeles. The hot sun was shining on my face. The sun was shining through my office window. And there was a woman standing beside me. She was calling my name. But she was angry with me. 'Mr Samuel. Wake up! Why are you sleeping at 11.45 in the morning?' The woman was about twenty-five years old. She had long dark hair.
  •    </div>
  •   </div>
  •  </div>
  •  <script>
  •   /*JavaScript*/
  •   document.getElementById("div2").style.backgroundAttachment = "scroll";
  •   /*jQuery*/
  •   $(document).ready(function () {
  •    $("#div3").css({ "background-attachment": "local" });
  •   });
  •  </script>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <link href="css/style.css" rel="stylesheet" />
  •  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  • </head>
  • <body>
  •  <div class="main">
  •   <div class="wrapper">
  •    <div id="div1">
  •     I was dreaming about Hawaii. I was dreaming about my holiday. In my dream, I was on the beach in Hawaii. The hot sun was shining on my face. The sound of the sea was all around me. But it was a dream. Three weeks ago, I had been lying on a beach in Hawaii. But I was not in Hawaii now. I was dreaming in my office in Los Angeles. I had returned from my holiday and there was no work for me. Nobody wanted to hire me. I went to my office every day, but the telephone didn't ring. So I slept in my chair and I dreamt about Hawaii. I was dreaming a wonderful dream. The sun was hot. The noise of the sea was loud and there was a beautiful woman standing next to me. Suddenly, there was a voice in my dream. Somebody was calling my name. 'Mr Samuel! Mr Samuel, wake up! Please, wake up! I want to talk to you.' I opened my eyes. It was April in Los Angeles. The hot sun was shining on my face. The sun was shining through my office window. And there was a woman standing beside me. She was calling my name. But she was angry with me. 'Mr Samuel. Wake up! Why are you sleeping at 11.45 in the morning?' The woman was about twenty-five years old. She had long dark hair.
  •    </div>
  •   </div>
  •   <div class="wrapper">
  •    <div id="div2">
  •     I was dreaming about Hawaii. I was dreaming about my holiday. In my dream, I was on the beach in Hawaii. The hot sun was shining on my face. The sound of the sea was all around me. But it was a dream. Three weeks ago, I had been lying on a beach in Hawaii. But I was not in Hawaii now. I was dreaming in my office in Los Angeles. I had returned from my holiday and there was no work for me. Nobody wanted to hire me. I went to my office every day, but the telephone didn't ring. So I slept in my chair and I dreamt about Hawaii. I was dreaming a wonderful dream. The sun was hot. The noise of the sea was loud and there was a beautiful woman standing next to me. Suddenly, there was a voice in my dream. Somebody was calling my name. 'Mr Samuel! Mr Samuel, wake up! Please, wake up! I want to talk to you.' I opened my eyes. It was April in Los Angeles. The hot sun was shining on my face. The sun was shining through my office window. And there was a woman standing beside me. She was calling my name. But she was angry with me. 'Mr Samuel. Wake up! Why are you sleeping at 11.45 in the morning?' The woman was about twenty-five years old. She had long dark hair.
  •    </div>
  •   </div>
  •   <div class="wrapper">
  •    <div id="div3">
  •     I was dreaming about Hawaii. I was dreaming about my holiday. In my dream, I was on the beach in Hawaii. The hot sun was shining on my face. The sound of the sea was all around me. But it was a dream. Three weeks ago, I had been lying on a beach in Hawaii. But I was not in Hawaii now. I was dreaming in my office in Los Angeles. I had returned from my holiday and there was no work for me. Nobody wanted to hire me. I went to my office every day, but the telephone didn't ring. So I slept in my chair and I dreamt about Hawaii. I was dreaming a wonderful dream. The sun was hot. The noise of the sea was loud and there was a beautiful woman standing next to me. Suddenly, there was a voice in my dream. Somebody was calling my name. 'Mr Samuel! Mr Samuel, wake up! Please, wake up! I want to talk to you.' I opened my eyes. It was April in Los Angeles. The hot sun was shining on my face. The sun was shining through my office window. And there was a woman standing beside me. She was calling my name. But she was angry with me. 'Mr Samuel. Wake up! Why are you sleeping at 11.45 in the morning?' The woman was about twenty-five years old. She had long dark hair.
  •    </div>
  •   </div>
  •  </div>
  •  <script>
  •   /*JavaScript*/
  •   document.getElementById("div2").style.backgroundAttachment = "scroll";
  •   /*jQuery*/
  •   $(document).ready(function () {
  •    $("#div3").css({ "background-attachment": "local" });
  •   });
  •  </script>
  • </body>
  • </html>