Page Widget How to - Stack border to create custom two layer border








Question

We would like to know how to stack border to create custom two layer border.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.border {<!-- www  .j a v a2  s . co m-->
  display: inline-block;
  position: relative;
  padding: .5em;
  border-top: 5px solid #894b9d;
}

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

The code above is rendered as follows: