CSS Only 3D Buttons

Author: SayanBarcha
Views Total: 163 views
Official Page: Go to website
Last Update: March 1, 2022
License: MIT

Preview:

CSS Only 3D Buttons

Description:

This is a short tutorial on how to create 3D web buttons using CSS3 transforms (rotate, skew, and translate).

How to use it:

1. Create a list of links for the 3D buttons.

<ul class="threeDbutton">
  <li>
    <a href="#">
      <span>3D Button 1 </span>
    </a>
  </li>
  <li>
    <a href="#">
      <span>3D Button 2 </span>
    </a>
  </li>
  <li>
    <a href="#">
      <span>3D Button 3 </span>
    </a>
  </li>
  ...
</ul>

2. Convert the links into 3D buttons.

See also  16+ Pure HTML / CSS Loading Spinners - Spinners.css

ul.threeDbutton{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  margin: 0;
  padding: 0;
}
ul.threeDbutton li{
  list-style: none;
  margin: 0 5px;
}
ul.threeDbutton li a span{
  padding: 0;
  margin: 0;
  position: absolute;
  top: 30px;
  color: #333;
  letter-spacing: 4px;
  transition: 0.5s;
}
ul.threeDbutton li a{
  text-decoration: none;
  display: absolute;
  display: block;
  width: 210px;
  height: 80px;
  background: #fff;
  text-align: left;
  padding-left: 20px;
  transform: rotate(-30deg) skewX(25deg) translate(0,0);
  transform: 0.5s;
  box-shadow: -20px 20px 10px rgba(0, 0, 0, 0.5);
}
ul.threeDbutton li a::before{
  content: '';
  position: absolute;
  top: 10px;
  left: -20px;
  height: 100%;
  width: 20px;
  background: #b1b1b1;
  transform: 0.5s;
  transform: rotate(0deg) skewY(-45deg);
}
ul.threeDbutton li a::after{
  content: '';
  position: absolute;
  bottom: -20px;
  left: -10px;
  height: 20px;
  width: 100%;
  background: #b1b1b1;
  transform: 0.5s;
  transform: rotate(0deg) skewX(-45deg);
}

3. Apply a hover effect o the buttons.

ul.threeDbutton li a:hover{
  transform: rotate(-30deg) skew(25deg) translate(20px, -15px);
  box-shadow: -50px 50px 50px rgba(0, 0, 0, 0.5);
}
ul.threeDbutton li:hover span{
  color: #fff;
}
ul.threeDbutton li:hover a{
  background: #dd4b39;
}
ul.threeDbutton li:hover a::before{
  background: #b33a2b;
}
ul.threeDbutton li:hover a::after{
  background: #e66a5a;
}

See also  Windows 95 Theme For Bootstrap 4 - Win95.css

Leave a Reply

Your email address will not be published. Required fields are marked *