Styling it using CSS
- .box {
- background-color: #e1e1e6;
- width: 400px;
- height: 100px;
- border: 1px solid black;
- border-radius: 5px;
- }
-
-
-
-
- .red {
- position: relative;
- top: 36px;
- left: 35%;
- text-decoration: none;
- color: #fff;
- background: #cb2727;
- text-align: center;
- padding: 20px 30px;
- width: 115px;
- border-radius: 5px;
- border: solid 1px #ec3838;
- transition: all 0.1s;
- -webkit-box-shadow: 0px 9px 0px #a81515;
-
- -moz-box-shadow: 0px 9px 0px #a81515;
-
- -o-box-shadow: 0px 9px 0px #a81515;
-
- -ms-box-shadow: 0px 9px 0px #a81515;
-
- }
Here we set text-decoration to none so that link underline removed. After that
adjusted color and background-color. Then set text-align and padding. Important
Step here is transition and box-shadow.
CSS3 transitions are effects that let an element gradually change from one style
to another.
Preview
Final step (Adding CSS for :active)
The : active selector is used to select and style the active link. A link
becomes active when you click on it.
- .red:active {
- -webkit-box-shadow: 0px 2px 0px #a81515;
- position: relative;
- top: 43px;
- }
The main trick behind this button's working is that decrease box-shadow and move
the position slightly down so that appears pressing down
Preview (working)
That's all.