CSS Property Value How to - Compare background-origin








Question

We would like to know how to compare background-origin.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!--  ww w .j  ava2 s  .  c  o  m-->
  width: 100px;
  height: 100px;
  background: url(http://placehold.it/200x200) 0
    0 no-repeat;
  padding: 20px;
  border: 20px solid transparent;
  float: left
}

#myDiv1 {
  -moz-background-origin: border;
  -webkit-background-origin: border;
  -webkit-background-origin: border-box;
  background-origin: border-box;
}

#myDiv2 {
  -moz-background-origin: padding;
  -webkit-background-origin: padding;
  -webkit-background-origin: padding-box;
  background-origin: padding-box;
}

#myDiv3 {
  -moz-background-origin: content;
  -webkit-background-origin: content;
  -webkit-background-origin: content-box;
  background-origin: content-box;
}
</style>
</head>
<body>
  <div id="myDiv1"></div>
  <div id="myDiv2"></div>
  <div id="myDiv3"></div>
</body>
</html>

The code above is rendered as follows: