CSS Property Value How to - width: calc(100% - 5px);








Question

We would like to know how to width: calc(100% - 5px);.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.container {<!--  www .  j av a 2 s.  c  o  m-->
  width: 120px;
  height: 100px;
  margin: 0;
  padding: 0;
  clear: both;
  background-color: blue;
}

.child {
  width: calc(100% - 5px);
  height: calc(100% - 5px);
  border: 5px solid red;
}
</style>
</head>
<body>
  <div class="container">
    <div class="child">text</div>
  </div>
</body>
</html>

The code above is rendered as follows: