CSS Layout How to - Create CSS Arrow Down








Question

We would like to know how to create CSS Arrow Down.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.arrow {<!--from w w  w .j  a  va2  s.co m-->
  width: 0px;
  height: 0px;
  left: 100px;
  top: 200px;
  position: relative;
}

.arrow:after, .arrow:before {
  bottom: 0%;
  left: 0%;
  border: solid transparent;
  content: " ";
  height: 0;
  width: 0;
  position: absolute;
}

.arrow:after {
  bottom: 6px;
  left: 0px;
  border-top-color: #eaeaea;
  border-width: 50px;
  margin-left: -50px;
}

.arrow:before {
  border-top-color: #20204d;
  border-width: 53px;
  margin-left: -53px;
}
</style>
</head>
<body>
  <div class="arrow">
    <p></p>
  </div>
</body>
</html>

The code above is rendered as follows: