Page Widget How to - Create CSS triangles borders








Question

We would like to know how to create CSS triangles borders.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.arrow {<!-- w ww  .  j a va2 s. co m-->
  width: 0px;
  height: 0px;
}

.right {
  border-top: 20px solid transparent;
  border-left: 20px solid green;
  border-bottom: 20px solid transparent;
}

.left {
  border-top: 20px solid transparent;
  border-right: 20px solid green;
  border-bottom: 20px solid transparent;
}

.down {
  border-left: 20px solid transparent;
  border-top: 20px solid green;
  border-right: 20px solid transparent;
}

.up {
  border-left: 20px solid transparent;
  border-bottom: 20px solid green;
  border-right: 20px solid transparent;
}
</style>
</head>
<body>
  <div class="arrow right"></div>
    <div class="arrow down"></div>
    <div class="arrow left"></div>
    <div class="arrow up"></div>
</body>
</html>

The code above is rendered as follows: