LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

3December

Cube Cat

A CSS Perspective exercise

CSS
/* Imported Font from google fonts */
@import url("https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,900");
/* Color palette */
/* General Styles */
body, html {
  font-family: 'Source Sans pro', sans-serif;
  background-color: #FAFAFA;
  font-size: 18px;
}

.sections, header, .container, footer {
  padding: 40px;
}
@media (min-width: 960px) {
  .sections, header, .container, footer {
    padding: 40px calc( (100% - 900px)/2 );
  }
}

header {
  text-align: center;
}
header h2 {
  font-size: 32px;
  color: #00171F;
}
header h3 {
  width: 140px;
  margin: auto;
  padding-top: 20px;
  color: #003459;
  border-top: rgba(0, 52, 89, 0.25) dotted 2px;
}
header p {
  color: #333333;
}

.container {
  position: relative;
  overflow: visible;
  min-height: 240px;
  -webkit-perspective: 800px;
          perspective: 800px;
}

/* Cube Cat */
.cube {
  height: 240px;
  width: 240px;
  margin: auto;
  left: 0;
  right: 0;
  overflow: visible;
  position: absolute;
  -webkit-transform-style: preserve-3d;
          transform-style: preserve-3d;
  -webkit-animation: rotation 5s linear infinite;
          animation: rotation 5s linear infinite;
}

.side {
  height: 160px;
  position: absolute;
  width: 200px;
}

.eye {
  height: 40px;
  width: 40px;
  background-color: #FAFAFA;
  position: absolute;
  top: 60px;
}

.eye--left {
  left: 20px;
}

.eye--right {
  right: 20px;
}

.nose {
  position: relative;
  height: 0;
  width: 0;
  top: 80px;
  margin-left: 50%;
  left: -10px;
  border-color: transparent;
  border-top-color: #FAFAFA;
  border-style: solid;
  border-width: 10px;
}

.side--ear:after, .side--a:after, .side--b:after, .side--c:after, .side--d:after, .side--ear:before, .side--a:before, .side--b:before, .side--c:before, .side--d:before {
  position: absolute;
  content: "";
  display: block;
  z-index: 99;
  height: 0;
  width: 0;
  top: -40px;
  border-color: transparent;
  border-bottom-color: #003459;
  border-style: solid;
  border-width: 20px 20px;
}
.side--ear:after, .side--a:after, .side--b:after, .side--c:after, .side--d:after {
  left: 0;
  border-left-width: 0;
}
.side--ear:before, .side--a:before, .side--b:before, .side--c:before, .side--d:before {
  right: 0;
  border-right-width: 0;
}

/* front */
.side--a {
  background-color: #003459;
  -webkit-transform: translate3d(0, 0, 100px);
          transform: translate3d(0, 0, 100px);
}

/* back */
.side--b {
  background-color: #003459;
  -webkit-transform: rotateX(180deg) translateZ(100px);
          transform: rotateX(180deg) translateZ(100px);
}
.side--b:after, .side--b:before {
  top: 160px;
  border-bottom-color: transparent;
  border-top-color: #003459;
}

/* left side */
.side--c {
  background-color: #00171F;
  -webkit-transform: rotateY(-90deg) translateZ(100px);
          transform: rotateY(-90deg) translateZ(100px);
}
.side--c:after, .side--c:before {
  border-bottom-color: #00171F;
}

/* right side*/
.side--d {
  background-color: #00171F;
  -webkit-transform: rotateY(90deg) translateZ(100px);
          transform: rotateY(90deg) translateZ(100px);
}
.side--d:after, .side--d:before {
  border-bottom-color: #00171F;
}

/* top */
.side--e {
  height: 200px;
  background-color: #00171F;
  -webkit-transform: rotateX(90deg) translateZ(100px);
          transform: rotateX(90deg) translateZ(100px);
}

/* bottom */
.side--f {
  height: 200px;
  background-color: #00171F;
  -webkit-transform: rotateX(-90deg) translateZ(60px);
          transform: rotateX(-90deg) translateZ(60px);
}

@-webkit-keyframes rotation {
  0% {
    -webkit-transform: rotateY(0deg) rotateX(0deg) rotateZ(0deg);
            transform: rotateY(0deg) rotateX(0deg) rotateZ(0deg);
  }
  50% {
    -webkit-transform: rotateY(190deg) rotateX(10deg) rotateZ(10deg);
            transform: rotateY(190deg) rotateX(10deg) rotateZ(10deg);
  }
  100% {
    -webkit-transform: rotateY(360deg) rotateX(0deg) rotateZ(0deg);
            transform: rotateY(360deg) rotateX(0deg) rotateZ(0deg);
  }
}

@keyframes rotation {
  0% {
    -webkit-transform: rotateY(0deg) rotateX(0deg) rotateZ(0deg);
            transform: rotateY(0deg) rotateX(0deg) rotateZ(0deg);
  }
  50% {
    -webkit-transform: rotateY(190deg) rotateX(10deg) rotateZ(10deg);
            transform: rotateY(190deg) rotateX(10deg) rotateZ(10deg);
  }
  100% {
    -webkit-transform: rotateY(360deg) rotateX(0deg) rotateZ(0deg);
            transform: rotateY(360deg) rotateX(0deg) rotateZ(0deg);
  }
}
/* faces */
.side--a .eye {
  border-radius: 50%;
}

.side--b .eye {
  height: 20px;
  border-radius: 20px 20px 0 0;
  bottom: 60px;
  top: auto;
}
.side--b .nose {
  border-top-color: transparent;
  border-bottom-color: #FAFAFA;
  top: 60px;
}

.side--c .eye {
  height: 20px;
  border-radius: 20px 20px 0 0;
}

.side--d .eye {
  background-color: transparent;
  border-width: 4px;
  border-style: solid;
  border-color: #FAFAFA;
  border-right-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
  -webkit-transform: rotate(45deg);
          transform: rotate(45deg);
}

/* Footer */
footer {
  background-color: #00171F;
  color: #FAFAFA;
}

.footer__title {
  font-size: 30px;
  margin-top: 40px;
}

.footer__subtitle {
  font-size: 22px;
  color: #00A7E1;
}

.footer__parragraph, .footer__list, .copyright {
  line-height: 1.5em;
  font-size: 22px;
}
.footer__parragraph a, .footer__list a, .copyright a {
  color: #00A75F;
}

.copyright {
  text-align: center;
  border-top: 1px dashed rgba(250, 250, 250, 0.15);
  padding: 10px 0;
  margin: 40px auto;
}

Description

I made this pen to understand CSS perspective property.
Term
Wed, 12/06/2017 - 19:44

Related Codes

Pen ID
Pen ID
Pen ID
Square Adv