Page Widget How to - Overlap div to create custom border








Question

We would like to know how to overlap div to create custom border.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.border {<!--   w ww . j  av  a 2s.c  om-->
  width: 200px;
  height: 200px;
  border-top: 5px solid #894b9d;
  padding: 0 1px 1px 1px;
  position: relative;
}

.border::after {
  display: block;
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 200px;
  height: 200px;
  border-color: #dad9d9;
  border-style: solid;
  border-width: 0 1px 1px 1px;
}
</style>
</head>
<body>
  <div class="border"></div>
</body>
</html>

The code above is rendered as follows: