Page Widget How to - Create triangular shape with border color








Question

We would like to know how to create triangular shape with border color.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.pointer {<!-- w w  w  .  j ava2  s  .  c  o  m-->
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-left: 10px solid red;
  border-bottom: 5px solid transparent;
  position: relative;
}

.pointer:before {
  content: '';
  position: absolute;
  left: -15px;
  top: -10px;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-left: 20px solid black;
  border-bottom: 10px solid transparent;
  z-index: -1;
}
</style>
</head>
<body>
  <div class='pointer'></div>
</body>
</html>

The code above is rendered as follows: