Halo teman teman.. klai ini kita akan belajar Membuat 3D Button dengan HTML dan CSS, oke langsung saja kita praktekan yah teman teman.

buka text editor kalian dan ketika kode HTML berikut dan beri nama index.html

index.html

 

<!DOCTYPE html>
 <html lang="en">
 <head>
   <meta charset="UTF-8">
   <title> Button 3D</title>
   <link rel="stylesheet" href="style.css">  
 </head>
 <body>
    <button class="button">
      <span class="button__inner"> 3D Tombol </span>
    </button>

    <button class="button button--secondary">
      <span class="button__inner"> button </span>
    </button>
 </body>
 </html>

lalu setelah itu ketika kode css berikut dan beri nama dengan anam style.css

style.css

 

	@import url(https://fonts.googleapis.com/css?family=Dosis);
* {
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
}

.button {
  font-size: 5vw;
  border: none;
  background-color: #ebebf0;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  position: relative;
  z-index: 1;
  padding: 0;
}
@media (min-width: 40em) {
  .button {
    font-size: 2em;
  }
}
.button:before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 10px;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: rgba(0, 10, 50, 0.2);
  -webkit-transition: -webkit-transform 0.6s cubic-bezier(0, 0.9, 0.13, 0.9);
  transition: -webkit-transform 0.6s cubic-bezier(0, 0.9, 0.13, 0.9);
  transition: transform 0.6s cubic-bezier(0, 0.9, 0.13, 0.9);
  transition: transform 0.6s cubic-bezier(0, 0.9, 0.13, 0.9), -webkit-transform 0.6s cubic-bezier(0, 0.9, 0.13, 0.9);
  -webkit-transform: translate3D(0, 0, 0);
          transform: translate3D(0, 0, 0);
}
.button:after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background-color: #ebebf0;
  z-index: -1;
}
.button:hover:before, .button:focus:before {
  -webkit-transform: translate3D(10px, 0, 0);
          transform: translate3D(10px, 0, 0);
}
.button:active:before {
  -webkit-transform: translate3D(0, 0, 0);
          transform: translate3D(0, 0, 0);
}
.button:focus, .button:active {
  outline: none;
}
.button .button__inner {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #333;
  padding: 1em 1.5em;
  background-color: #fbfbfb;
  display: block;
  width: 100%;
  height: 100%;
  -webkit-transition: -webkit-transform 0.6s cubic-bezier(0, 0.9, 0.13, 0.9);
  transition: -webkit-transform 0.6s cubic-bezier(0, 0.9, 0.13, 0.9);
  transition: transform 0.6s cubic-bezier(0, 0.9, 0.13, 0.9);
  transition: transform 0.6s cubic-bezier(0, 0.9, 0.13, 0.9), -webkit-transform 0.6s cubic-bezier(0, 0.9, 0.13, 0.9);
  position: relative;
}
.button:hover .button__inner, .button:focus .button__inner {
  -webkit-transform: translate3D(0, -10px, 0);
          transform: translate3D(0, -10px, 0);
}
.button:active .button__inner {
  -webkit-transform: translate3D(0, 0, 0);
          transform: translate3D(0, 0, 0);
}
.button:hover .button__inner, .button:focus .button__inner {
  background-color: #fff;
}

.button--secondary {
  background-color: #00d18e;
  z-index: 0;
}
.button--secondary:after {
  background-color: #c0392b;
}
.button--secondary .button__inner {
  background-color: #e74c3c;
}
.button--secondary:hover .button__inner, .button--secondary:focus .button__inner {
  background-color: #e74c3c;
}

html,
body {
  background-color: #ecf0f1;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  width: 100%;
  height: 100%;
  font-family: "Dosis", cursive;
}

bila sudah maka hasilnya seperti gambar di bawah ini

sekian tutorial Membuat 3D Button dengan HTML dan CSS, semoga bermanfaat 😀