Page Widget How to - Create CSS3 Rounded Tab








Question

We would like to know how to create CSS3 Rounded Tab.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.tab {<!--from   www  . java  2 s .  co  m-->
  background: gray;
  color: white;
  text-shadow: 0 -1px 0 black;
  display: inline-block;
  padding: 0 10px;
  margin: 5px 25px;
  height: 30px;
  line-height: 30px;
  position: relative;
  border: 1px solid black;
  border-width: 1px 0;
  box-sizing: border-box;
}

.tab::before, .tab::after {
  background: gray;
  box-sizing: border-box;
  border: 1px solid black;
  display: block;
  position: absolute;
  content: "";
  height: 30px;
  width: 30px;
  top: -1px;
  z-index: -1;
}

.tab::before {
  left: -15px;
  border-radius: 0 5px;
  -webkit-transform: skew(25deg, 0deg);
}

.tab::after {
  right: -15px;
  border-radius: 5px 0;
  -webkit-transform: skew(-25deg, 0deg);
}
</style>
</head>
<body>
  <ul>
    <li class="tab">Rounded Tab</li>
    <li class="tab">A</li>
    <li class="tab">R</li>
    <li class="tab">T</li>
    <li class="tab">Tab</li>
    <li class="tab">Tab</li>
  </ul>
</body>
</html>

The code above is rendered as follows: