Page Widget How to - Create CSS Ribbon








Question

We would like to know how to create CSS Ribbon.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!--from   w  ww . jav a  2  s.c  om-->
  width: 150px;
  height: 50px;
  background: #f4496f;
  position: relative;
  border-radius: 4px;
}

div:after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-width: 25px 25px 25px 0;
  border-style: solid;
  border-color: #f4496f #fff;
}

div:before {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 3px;
  border-width: 0px 16px 8px 0;
  border-style: solid;
  border-color: #fff #6b061d;
}

a {
  text-decoration: none;
  color: #6b061d;
  font-size: 20px;
  font-family: sans-serif;
  line-height: 50px;
  margin-left: 20px;
  text-shadow: 0 1px 0 #fbb9c8;
}
</style>
</head>
<body>
  <div>
    <a href="http://java2s.com">Home</a>
  </div>
</body>
</html>

The code above is rendered as follows: