Hai, jumpa lagi dengan saya, seperti biasa saya tidak akan bosan-bosan untuk berbagi tutorial lagi, kali ini saya akan kasih tau bagaimana Cara Membuat Animasi 3D Dengan HTML-CSS, sebenarnya banyak sekali cara untuk membuat animasi 3D, namun kali ini saya akan membuatnya dengan hanya menggunakan HTML-CSS. Berikut langkah-langkahnya.

Seperti biasa, silahkan buka dulu teks editornya, kalo sudah silahkan ketika kode HTML berikut.

<div class="wrap wrap-defaults">
  <div class="box-rotate-wrap">
    <div class="box box-rotate box-rotate-top">
      <div class="front">
        <h2>Front</h2> This is on front.
      </div>
      <div class="back">
        <h2>Back</h2>
      </div>
      <div class="top">
        <h2>Top</h2> This is what will be shown.
      </div>
      <div class="bottom">
        <h2>Bottom</h2>
      </div>
      <div class="left">
        <h2>Left</h2>
      </div>
      <div class="right">
        <h2>Right</h2>
      </div>
    </div>
  </div>

  <div class="box-rotate-wrap">
    <div class="box box-rotate box-rotate-bottom">
      <div class="front">
        <h2>Front</h2> This is on front.
      </div>
      <div class="back">
        <h2>Back</h2>
      </div>
      <div class="top">
        <h2>Top</h2>
      </div>
      <div class="bottom">
        <h2>Bottom</h2> This is what will be shown.
      </div>
      <div class="left">
        <h2>Left</h2>
      </div>
      <div class="right">
        <h2>Right</h2>
      </div>
    </div>
  </div>

  <div class="box-rotate-wrap">
    <div class="box box-rotate box-rotate-left">
      <div class="front">
        <h2>Front</h2> This is on front.
      </div>
      <div class="back">
        <h2>Back</h2>
      </div>
      <div class="top">
        <h2>Top</h2>
      </div>
      <div class="bottom">
        <h2>Bottom</h2>
      </div>
      <div class="left">
        <h2>Left</h2> This is what will be shown.
      </div>
      <div class="right">
        <h2>Right</h2>
      </div>
    </div>
  </div>

  <div class="box-rotate-wrap">
    <div class="box box-rotate box-rotate-right">
      <div class="front">
        <h2>Front</h2> This is on front.
      </div>
      <div class="back">
        <h2>Back</h2>
      </div>
      <div class="top">
        <h2>Top</h2>
      </div>
      <div class="bottom">
        <h2>Bottom</h2>
      </div>
      <div class="left">
        <h2>Left</h2>
      </div>
      <div class="right">
        <h2>Right</h2> This is what will be shown.
      </div>
    </div>
  </div>

  <div class="box-rotate-wrap">
    <div class="box box-rotate box-rotate-back">
      <div class="front">
        <h2>Front</h2> This is on front.
      </div>
      <div class="back">
        <h2>Back</h2> This is what will be shown.
      </div>
      <div class="top">
        <h2>Top</h2>
      </div>
      <div class="bottom">
        <h2>Bottom</h2>
      </div>
      <div class="left">
        <h2>Left</h2>
      </div>
      <div class="right">
        <h2>Right</h2>
      </div>
    </div>
  </div>

  <div class="box-rotate-wrap">
    <div class="box box-rotate box-rotate-gyro">
      <div class="front">
        <h2>Front</h2> This is on front.
      </div>
      <div class="back">
        <h2>Back</h2> This is what will be shown.
      </div>
      <div class="top">
        <h2>Top</h2>
      </div>
      <div class="bottom">
        <h2>Bottom</h2>
      </div>
      <div class="left">
        <h2>Left</h2>
      </div>
      <div class="right">
        <h2>Right</h2>
      </div>
    </div>
  </div>
</div>

Setelah itu, lanjutkan lagi dengan mengetikan kode CSS berikut untuk membuat animasi 3D nya.

$boxwidth: 200px;
$boxheight: 200px;

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}
body {
	padding: 100px;
	font-family: Arial, sans-serif;
}
h1, h2, h3, p {
	margin: 0 0 1em;
}
.wrap:after {
	content: "";
	display: block;
	clear: both;
}
.box-rotate-wrap {
	float: left;
	margin: 0 30px 30px 0;
	perspective: 1000px;
}
.box, .box > div {
	width: $boxwidth;
	height: $boxheight;
}

.box-rotate {
	position: relative;
	transition: all 0.8s ease;
	transform-style: preserve-3d;
	transform: translate3d(0, 0, -$boxheight/2);
}
.box-rotate > div {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 1;
	background: #fff;
	padding: 20px;
  overflow: auto;
}
.box-rotate .front {
	background: cyan;
	z-index: 2;
	transform: rotate3d(0, 1, 0, 0deg) translate3d(0, 0, $boxwidth/2);
}
.box-rotate .back {
	background: orange;
	transform: rotate3d(0, 1, 0, 180deg) rotate(180deg) translate3d(0, 0, $boxwidth/2);
}
.box-rotate .top {
	background: purple;
	height: $boxwidth;
	transform: rotate3d(1, 0, 0, 90deg) translate3d(0, 0, $boxwidth/2);
}
.box-rotate .bottom {
	background: blue;
	height: $boxwidth;
	transform: rotate3d(1, 0, 0, -90deg) translate3d(0, 0, $boxheight - $boxwidth/2);
}
.box-rotate .left {
	background: yellow;
	transform: rotate3d(0, 1, 0, -90deg) translate3d(0, 0, $boxwidth/2);
}
.box-rotate .right {
	background: green;
	transform: rotate3d(0, 1, 0, 90deg) translate3d(0, 0, $boxwidth/2);
}

.box-rotate-top:hover {
	transform: translate3d(0, 0, -$boxwidth/2) rotate3d(1, 0, 0, -90deg);
}
.box-rotate-bottom:hover {
	transform: translate3d(0, 0, -$boxwidth/2) rotate3d(1, 0, 0, 90deg);
}
.box-rotate-left:hover {
	transform: translate3d(0, 0, -$boxwidth/2) rotate3d(0, 1, 0, 90deg);
}
.box-rotate-right:hover {
	transform: translate3d(0, 0, -$boxwidth/2) rotate3d(0, 1, 0, -90deg);
}
.box-rotate-back:hover {
	transform: translate3d(0, 0, -$boxwidth/2) rotate3d(1, 0, 0, -180deg);
}
.box-rotate-gyro .back {
	width: $boxheight;
	height: $boxwidth;
	transform: rotate3d(0, 1, 0, 180deg) rotate(90deg) translate3d($boxheight/2 - $boxwidth/2, -$boxheight/2 + $boxwidth/2, $boxwidth/2);
}
.box-rotate-gyro:hover {
	transform: translate3d(0, 0, -$boxwidth/2) rotate3d(1, 1, 0, -180deg);
}

.box.box-blend div {
	background: #fff;
	box-shadow: 0 0 1px rgba(0,0,0,.8);
}

Kalo sudah semuanya diketikan, jangan lupa disimpan, kemudian coba jalankan di browsernya masing-masing, dan lihat hasilnya. Selesai.

Baik itulah tutorial bagaimana Cara Membuat Animasi 3D Dengan HTML-CSS, silahkan kalian modifikasi lagi, bisa dengan menggunakan gambar atau dengan yang lainnya. Sampai ketemu dilain kesempatan.

Selamat mencoba.