background-clip



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


  • border-box
  • padding-box
  • content-box



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: 250px;
  •  width: 250px;
  •  float: left;
  •  position: relative;
  •  top: 50%;
  •  left: 50%;
  •  margin-top: -125px;
  •  margin-left: -125px;
  •  border: 5px dotted #00F;
  •  background-color: #A3E61D;
  •  padding: 15px;
  • }
  •  
  • #div1 {
  •  background-clip: border-box;
  • }
* {
 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: 250px;
 width: 250px;
 float: left;
 position: relative;
 top: 50%;
 left: 50%;
 margin-top: -125px;
 margin-left: -125px;
 border: 5px dotted #00F;
 background-color: #A3E61D;
 padding: 15px;
} 

#div1 {
 background-clip: border-box;
}


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.
  •    </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.
  •    </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.
  •    </div>
  •   </div>
  •  </div>
  •  <script>
  •   /*JavaScript*/
  •   document.getElementById("div2").style.backgroundClip = "padding-box";
  •   /*jQuery*/
  •   $(document).ready(function () {
  •    $("#div3").css({ "background-clip": "content-box" });
  •   });
  •  </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.
  •    </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.
  •    </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.
  •    </div>
  •   </div>
  •  </div>
  •  <script>
  •   /*JavaScript*/
  •   document.getElementById("div2").style.backgroundClip = "padding-box";
  •   /*jQuery*/
  •   $(document).ready(function () {
  •    $("#div3").css({ "background-clip": "content-box" });
  •   });
  •  </script>
  • </body>
  • </html>