HTML Form How to - Create a CSS3 Button








Question

We would like to know how to create a CSS3 Button.

Answer


<!--from   w w w  .  j a v a  2  s  .c o m-->
<!--
Revised from
http://fiddle.jshell.net/bozdoz/ehm4M/1/show/light/
-->
<!DOCTYPE html>
<html>
<head>
  <style type='text/css'>
.button {
    background-color: #296;
    box-shadow: 0 0 0 1px #060 inset,0 0 0 2px rgba(255, 255, 255, 0.15) inset,0 8px 0 0 #040,0 8px 0 1px rgba(0, 0, 0, 0.4),0 8px 8px 1px rgba(0, 0, 0, 0.5);
    display: block;
    font-size: 22px;
    height: 61px;
    line-height: 61px;
    position: relative;
    text-align: center;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
    -webkit-transition: all .1s linear;
    width: 186px;
}
.button:hover {
    background-color: #3a7;
    box-shadow: 0 0 0 1px #070 inset,0 0 0 2px rgba(255, 255, 255, 0.15) inset,0 10px 0 0 #050,0 10px 0 1px rgba(0, 0, 0, 0.4),0 10px 8px 1px rgba(0, 0, 0, 0.6);
    margin-top: 26px;
    margin-bottom: 12px;
}
.button:active {
    background-color:#074;
    box-shadow: 0 0 0 1px #296 inset,0 0px 0 2px rgba(255, 255, 255, 0.15) inset,0 0 0 1px rgba(0, 0, 0, 0.4);
    margin-top: 35px;
    margin-bottom: 3px;
}
  </style>
</head>
<body>
      <a href="#" class="button">Enter</a>
</body>
</html>

The code above is rendered as follows: