CSS Layout How to - Use padding to shrink an element "100%-50px"








Question

We would like to know how to use padding to shrink an element "100%-50px".

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.outer {<!--   w  w w  .j a  v  a  2  s .  c om-->
  height: 200px;
  padding: 0 50px 0 0;
  background: #EEE;
}

.inner {
  height: 100px;
  background: #ffa800;
}
</style>
</head>
<body>
  <div class="outer">
    <div class="inner">
      This is the inner div
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: