Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <section id="transforms" class="section-transforms">
  <h2 class="section-title title">5 Transforms <span>(2D &amp; 3D)</span></h2>

  <!-- 5.2 Transforms -->
  <article id="transforms">

    <!-- 5.2.1 2D Transforms -->
    <h4 id="transforms-2d-title" class="sub-section-title title">5.2.1 2D Transforms</h4>
    <article id="transforms-2d">
      <!--       <h5>5.1.1 Race Track (Curves)</h5> -->
      <ul class="transforms-list">
        <li>Translate
          <ul>
            <li>translateX</li>
            <li>translateY</li>
            <li>translate(X, Y)</li>
          </ul>
        </li>
        <li>Scale
          <ul>
            <li>scaleX</li>
            <li>scaleY</li>
            <li>scale(X, Y)</li>
          </ul>
        </li>
        <li>Skew
          <ul>
            <li>skewX</li>
            <li>skewY</li>
            <li>skew(X, Y)</li>
          </ul>
        </li>
        <li>Rotate</li>
        <li>Transform-origin</li>
        <li>Matrix</li>
      </ul>

      <div class="field field-2d">
        <div id="obj-2d"></div>
      </div>

      <div class="section-nav-buttons">
        <a class="prev-section" href="#layout-box-model">&uarr;</a>
        <a class="next-section end" href="#layout-box-model">&#8656;<span>Top</span></a>
      </div>
    </article>

    <!-- 5.2.2 3D Transforms -->
    <h4 id="transforms-3d-title" class="sub-section-title title">5.2.2 3D Transforms</h4>
    <article id="transforms-3d">
      <!--       <h5>5.1.1 Race Track (Curves)</h5> -->
      <ul class="transforms-list">
        <li><a href="#">Perspective</a></li>
        <li>Transform-origin</li>
        <li>Translate
          <ul>
            <li>translateX</li>
            <li>translateY</li>
            <li>translateZ</li>
            <li>translate3d( x, y, z )</li>
          </ul>
        </li>
        <li>Scale
          <ul>
            <li>scaleX</li>
            <li>scaleY</li>
            <li>scaleZ</li>
            <li>scale3d( x, y, z )</li>
          </ul>
        </li>
        <li>Rotate
          <ul>
            <li>rotateX</li>
            <li>rotateY</li>
            <li>rotateZ</li>
            <li>rotate3d( x, y, z )</li>
          </ul>
        </li>
        <li>Matrix</li>
      </ul>

      <div class="field field-3d">
        <div id="obj-3d"></div>
      </div>

      <div class="section-nav-buttons">
        <a class="prev-section" href="#layout-box-model">&uarr;</a>
        <a class="next-section end" href="#layout-box-model">&#8656;<span>Top</span></a>
      </div>
    </article>

    <!-- 5.2.3 Transform Origin -->
    <h4 id="transform-origin-title" class="sub-section-title title">5.2.3 Transform Origin &amp; Perspective</h4>
    <article id="transform-origin">
      <!--       <h5>5.1.1 Race Track (Curves)</h5> -->
      <ul class="movies-list">
        <li>On DVD
          <ul>
            <li>Doctor Strange</li>
            <li>Guardians of the Galaxy Vol. 2</li>
            <li>Thor: Ragnarok</li>
            <li>Black Panther</li>
          </ul>
        </li>
        <li>Upcoming
          <ul>
            <li>Doctor Strange 2</li>
            <li>Guardians of the Galaxy Vol. 3</li>
            <li>Thor: Love &amp; Thunder</li>
            <li>Morbius</li>
          </ul>
        </li>
      </ul>

      <div class="field field-movies">
        <div class="movie-shelf">
          <img class="movie-poster dr-strange" src="https://www.vintagemovieposters.co.uk/wp-content/uploads/2018/04/IMG_3052.jpg">
          <img class="movie-poster guardians" src="https://www.homewallmurals.co.uk/ekmps/shops/allwallpapers/images/marvel-guardians-of-the-galaxy-61x91-5cm-movie-posters-vol.-2-31632-1-p[ekm]693x1038[ekm].jpg">
          <img class="movie-poster thor" src="https://media.comicbook.com/2017/10/thor-3-movie-poster-marvel-cinematic-universe-1038915.png">
          <img class="movie-poster panther" src="https://thereelbits.com/wp-content/uploads/2018/02/BlackPanther_PayoffOneSheet.jpg">
          <img class="movie-poster dr-strange" src="https://img.gurugamer.com/resize/740x-/2020/04/10/doctor-strange-in-the-multiverse-of-madness-poster-0882.png">
          <img class="movie-poster guardians" src="https://droidjournal.com/wp-content/uploads/2020/06/1-9.jpg">
          <img class="movie-poster thor" src="https://i1.wp.com/honknews.com/wp-content/uploads/2019/12/Thor-love-and-thunder-fanmade-poster.jpg">
          <img class="movie-poster morbius" src="https://media.comicbook.com/2020/03/morbius-new-image-scary-1212689.jpeg">
        </div>
      </div>

      <div class="section-nav-buttons">
        <a class="prev-section" href="#layout-box-model">&uarr;</a>
        <a class="next-section end" href="#layout-box-model">&#8656;<span>Top</span></a>
      </div>
    </article>

    <!-- 5.2.4 Cards -->
    <h4 id="cards-title" class="sub-section-title title">5.2.4 Cards</h4>
    <article id="cards">
      <!--       <h5>5.1.1 Race Track (Curves)</h5> -->
      <ul class="card-notes">
        <li><strong>HTML notes:</strong>
          <ul>
            <li>Card div = card's physical area</li>
            <li>Card-inner = what flips</li>
            <li>Card-front = normal content</li>
            <li>Card-back = rotateY(180deg)</li>
          </ul>
        </li>
        <li><strong>CSS notes:</strong>
          <ul>
            <li>Card = set size + perspective</li>
            <li>Card-inner = transition + preserve-3d</li>
            <li>Card-face = backface-visibility: hidden</li>
            <li>Card-back = rotateY(180deg)</li>
            <li>Card-inner:hover = rotateY(180deg)</li>
          </ul>
        </li>
      </ul>

      <div class="field field-card">
        <div class="card">
          <div class="card-inner">
            <div class="card-face card-front"></div>
            <div class="card-face card-back"></div>
          </div>
        </div>
      </div>

      <div class="section-nav-buttons">
        <a class="prev-section" href="#layout-box-model">&uarr;</a>
        <a class="next-section end" href="#layout-box-model">&#8656;<span>Top</span></a>
      </div>
    </article>

    <!-- 5.2.5 Carousels -->
    <h4 id="carousels-title" class="sub-section-title title">5.2.5 Carousels</h4>
    <article id="carousels">
      <!--       <h5>5.1.1 Race Track (Curves)</h5> -->
      <ul class="carousel-notes">
        <li><strong>HTML notes:</strong>
          <ul>
            <li>Carousel-scene = container</li>
            <li>Carousel = what we will rotate</li>
            <li>Cells = multiple images / slides</li>
          </ul>
        </li>
        <li><strong>CSS notes:</strong>
          <ul>
            <li>Carousel-scene = setup, set perspective</li>
            <li>Carousel = preserve-3d, transition</li>
            <li>Cells = divide # cells by 360, rotateY, + translateZ</li>
            <li>Keyframes = rotateY - carousel</li>
          </ul>
        </li>
      </ul>

      <div class="field field-carousel">
        <div class="carousel-scene">
          <div class="carousel">
            <div class="cell"><img class="avengers-1" src="https://images-na.ssl-images-amazon.com/images/I/712nF0GZjJL._AC_SY679_.jpg"></div>
            <div class="cell"><img class="avengers-2" src="https://images-na.ssl-images-amazon.com/images/I/71wV2rzkFwL._AC_SY741_.jpg"></div>
            <div class="cell"><img class="avengers-2.5" src="https://images-na.ssl-images-amazon.com/images/I/81Am11cr%2B1L._AC_SL1334_.jpg"></div>
            <div class="cell"><img class="avengers-3" src="https://images-na.ssl-images-amazon.com/images/I/A1t8xCe9jwL._AC_SY741_.jpg"></div>
            <div class="cell"><img class="avengers-4" src="https://images-na.ssl-images-amazon.com/images/I/71niXI3lxlL._AC_SY679_.jpg"></div>
          </div>
        </div>
      </div>

      <div class="section-nav-buttons">
        <a class="prev-section" href="#layout-box-model">&uarr;</a>
        <a class="next-section end" href="#layout-box-model">&#8656;<span>Top</span></a>
      </div>
    </article>

    <!-- 5.2.6 Cubes & Boxes -->
    <h4 id="cubes-title" class="sub-section-title title">5.2.6 Cubes &amp; Boxes</h4>
    <article id="cubes">
      <!--       <h5>5.1.1 Race Track (Curves)</h5> -->
      <ul class="cube-notes">
        <li><strong>HTML notes:</strong>
          <ul>
            <li>Cube-scene = container</li>
            <li>Cube = what we will rotate</li>
            <li>Cube-face = multiple images</li>
          </ul>
        </li>
        <li><strong>CSS notes:</strong>
          <ul>
            <li>Cube-scene = width, height, perspective</li>
            <li>Cube = preserve-3d, rotate3d, transition</li>
            <li>Cube:hover = rotate3d differently</li>
            <li>Cube-face = Size, rotateY, translateZ (1/2 size)</li>
          </ul>
        </li>
      </ul>

      <div class="field field-cube">
        <div class="cube-scene">
          <div class="cube">
            <div class="cube-face cube-front"><img src="https://lumiere-a.akamaihd.net/v1/images/avengers-characterthumbnail-ironman_96bd4819.jpeg"></div>
            <div class="cube-face cube-back"><img src="https://lumiere-a.akamaihd.net/v1/images/avengers-characterthumbnail-captainamerica_65ba07ce.jpeg"></div>
            <div class="cube-face cube-right"><img src="https://lumiere-a.akamaihd.net/v1/images/avengers-characterthumbnail-thor_818c3376.jpeg"></div>
            <div class="cube-face cube-left"><img src="https://lumiere-a.akamaihd.net/v1/images/avengers-characterthumbnail-blackwidow_8b8b117b.jpeg"></div>
            <div class="cube-face cube-top"><img src="https://lumiere-a.akamaihd.net/v1/images/avengers-characterthumbnail-hulk_779919a1.jpeg"></div>
            <div class="cube-face cube-bottom"><img src="https://lumiere-a.akamaihd.net/v1/images/avengers-characterthumbnail-blackpanther_e647c782.jpeg"></div>
          </div>
        </div>
      </div>

      <div class="section-nav-buttons">
        <a class="prev-section" href="#layout-box-model">&uarr;</a>
        <a class="next-section end" href="#layout-box-model">&#8656;<span>Top</span></a>
      </div>
    </article>

  </article>
</section>
              
            
!

CSS

              
                /* ---------------------------------------------------
 * 0 Document Base Styles
 * ---------------------------------------------------*/
:root {
  --link-color: rgba(10, 47, 158, 1);
}

html {
  font-size: 62.5%;
  scroll-behavior: smooth;
}

body {
  font-size: 16px;
  font-family: Muli;
  margin: 0;
  color: #151025;
}

section {
  max-width: 100rem;
  margin: 0 auto;
  padding: 6rem;
  position: relative;
  background: #efefef;
}

a {
  color: rgba(10, 47, 158, 1);
}

a:hover,
a:active,
a:focus {
  color: rgba(53, 68, 255, 1);
}

a:visited {
  color: rgba(164, 88, 255, 1);
}

ul,
ol,
li {
  margin: 0;
  padding: 0;
}

ul ul {
  margin-left: 2rem;
}

.section-title {
  color: white;
  background: linear-gradient(
    240deg,
    rgba(164, 88, 255, 1) 0%,
    rgba(53, 68, 255, 1) 40%,
    rgba(10, 47, 158, 1) 80%
  );
  background-image: url("https://www.transparenttextures.com/patterns/stardust.png"),
    linear-gradient(
      240deg,
      rgba(164, 88, 255, 1) 0%,
      rgba(53, 68, 255, 1) 40%,
      rgba(10, 47, 158, 1) 80%
    );

  margin: -6rem -6rem 3rem;
  padding: 6rem;
}

.section-title span {
  font-size: 60%;
  opacity: 0.6;
}

article {
  min-height: calc(100vh - 6rem);
  padding: 3rem 0;
  position: relative;
}

.section-nav-buttons {
  font-size: 4.8rem;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 10rem;
}

.section-nav-buttons a {
  text-decoration: none;
}

.next-section.end {
  transform: rotate(90deg);
  display: inline-block;
}

.next-section.end span {
  font-size: initial;
  position: absolute;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
}

h2 {
  font-size: 4.4rem;
}

h3 {
  font-size: 3.6rem;
}

h4 {
  font-size: 3rem;
  position: relative;
}

h5 {
  padding-top: 0rem;
  margin-top: 0;
  font-size: 2.4rem;
}

article article article {
  padding: 0 10rem;
}

.col-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-gap: 1rem;
}

.title:before {
  content: "#";
  opacity: 0.3;
  position: absolute;
  left: 3.5rem;
  text-align: right;
}

.sub-section-title {
  background-image: url("https://www.transparenttextures.com/patterns/stardust.png"),
    linear-gradient(
      240deg,
      rgba(164, 88, 255, 1) 0%,
      rgba(53, 68, 255, 1) 40%,
      rgba(10, 47, 158, 1) 80%
    );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.sub-section-title:before {
  left: -2rem;
  -webkit-background-clip: text;
  -webkit-text-fill-color: initial;
}

.sub-section-title span {
  font-size: 50%;
  -webkit-text-fill-color: gray;
  opacity: 50%;
}

.font-notes {
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.pre-columns pre {
  background: #151025;
  color: #efefef;
  padding: 2rem 2rem 0;
}

/* ---------------------------------------------------
 * 5.2 Transforms
 * ---------------------------------------------------*/
.field,
.field-2d,
.field-3d {
  border: 2px solid hsl(240deg, 60%, 60%, 0.3);
  background: gainsboro;
  width: 600px;
  height: 400px;
  position: absolute;
  right: 0;
  top: 0;
}

#obj,
#obj-2d,
#obj-3d {
  background: red;
  height: 100px;
  width: 100px;
  display: block;
  position: absolute;
  top: 36%;
  right: 40%;
  /*   transform: translate(50%, -50%); */
  transition: all 2s;
}

/* ---------------------------------------------------
 * 5.2.1 2D Transforms
 * ---------------------------------------------------*/
#obj-2d {
  transform-origin: top left;
  /*   transform-origin: top; Show with rotation */

  /*     transform: translateX(-200px);
    transform: translateY(100px);
    transform: translate(-200px, 100px);

    transform: scaleX(2);
    transform: scaleY(3);
    transform: scale(2, 3);
    transform: scale(0.5);

    transform: skewX(30deg);
    transform: skewY(0.5rad);
    transform: skew(-0.05turn);
    transform: skew(35deg, 15deg); */

  transform: rotate(45deg);

  /* Order matters */
  transform: skew(25deg) rotate(45deg) translateX(100px) scale(1.5);
  /*     transform: scale(1.5) translateX(100px) rotate(45deg) skew(25deg); */

  /* Matrix */
  /* matrix( scaleX(), skewY(), skewX(), scaleY(), translateX(), translateY() ) */
  /*     transform: matrix(0.5, 1, -1, 0.5, 80, 80); */
}

#transforms-2d,
#transforms-2d-title {
  display: none;
}

/* ---------------------------------------------------
 * 5.2.2 3D Transforms
 * ---------------------------------------------------*/
.field-3d {
  perspective: 500px;
  /*   perspective-origin: 50% 50%; */
  transform-style: preserve-3d;
}

#obj-3d {
  transform: translateX(200px);
  transform: translateY(200px);
  transform: translateZ(200px);

  transform: scaleX(2);
  transform: scaleY(2);
  transform: scaleZ(2);

  transform: rotateX(45deg);
  transform: rotateY(45deg);
  transform: rotateZ(45deg);

  /* Order matters */
  transform: skew(25deg) rotateX(45deg) translateX(100px) scale(1.5);
  transform: scale(1.5) translateX(100px) rotateX(45deg) skew(25deg);

  /* Matrix3d */
  /* matrix3d(a1, b1, c1, d1, a2, b2, c2, d2, a3, b3, c3, d3, a4, b4, c4, d4) */
  /*     transform: matrix3d(2, 0, 3, 0, 0, 1.5, 0, 0, 2, 0, 1, 0, -50, -100, 0, 1.1); */
}

#transforms-3d,
#transforms-3d-title {
  display: none;
}

/* ---------------------------------------------------
 * 5.2.3 Transform Origin
 * ---------------------------------------------------*/
.field-movies {
  width: 616px;
}

.movie-shelf {
  transform: perspective(500px) rotateY(-30deg) translateX(-80px);
  /*     perspectice-origin: center center; */
  transform-style: preserve-3d;
}

.movie-poster {
  width: 150px;
  height: 200px;
  transform: rotateX(25deg) rotateY(-5deg);
  transform-origin: top;
  box-shadow: 4px 8px 16px;
}

#transform-origin,
#transform-origin-title {
  display: none;
}

/* ---------------------------------------------------
 * 5.2.4 Cards
 * ---------------------------------------------------*/
.field-card {
  display: flex;
  justify-content: center;
  align-items: center;
}

.card-notes {
  margin-bottom: 10rem;
}

.card {
  width: 200px;
  height: 300px;
  perspective: 600px;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 1s;
  transform-style: preserve-3d;
}

.card-face {
  position: absolute;
  height: 100%;
  width: 100%;
  backface-visibility: hidden;
}

.card-front {
  background: url(https://thumbor.forbes.com/thumbor/960x0/https%3A%2F%2Fblogs-images.forbes.com%2Falishagrauso%2Ffiles%2F2016%2F05%2Fcaptain-america-vs-iron-man-image-1600x1200-1200x900.jpg);
  background-size: cover;
}

.card-back {
  background: blue;
  transform: rotateY(180deg);
  background: url(https://thumbor.forbes.com/thumbor/960x0/https%3A%2F%2Fblogs-images.forbes.com%2Falishagrauso%2Ffiles%2F2016%2F05%2Fcaptain-america-vs-iron-man-image-1600x1200-1200x900.jpg);
  background-size: cover;
  background-position: top left 599px;
}

.card-inner:hover {
  transform: rotateY(-180deg);
}

#cards,
#cards-title {
  display: none;
}

/* ---------------------------------------------------
 * 5.2.5 Carousels
 * ---------------------------------------------------*/
.carousel-notes {
  margin-bottom: 14rem;
}

.carousel-scene {
  width: 210px;
  height: 140px;
  position: relative;
  perspective: 1000px;
  left: 200px;
  top: 30px;
}

.carousel {
  width: 100%;
  height: 100%;
  position: absolute;
  transform-style: preserve-3d;
  /*   transform: translateZ(-288px); */
  transition: transform 1s;
}

.cell {
  position: absolute;
  width: 200px;
  /*   transform-origin: 50% 50% 0px; */
}

.cell img {
  width: 100%;
}

.cell:nth-child(1) {
  transform: rotateY(0deg) translateZ(140px);
}
.cell:nth-child(2) {
  transform: rotateY(72deg) translateZ(140px);
}
.cell:nth-child(3) {
  transform: rotateY(144deg) translateZ(140px);
}
.cell:nth-child(4) {
  transform: rotateY(216deg) translateZ(140px);
}
.cell:nth-child(5) {
  transform: rotateY(288deg) translateZ(140px);
}

@keyframes spin {
  from {
    transform: rotateY(0deg);
  }
  to {
    transform: rotateY(360deg);
  }
}

.carousel:hover {
  animation: spin 6s infinite linear;
}

#carousels,
#carousels-title {
    display: none;
}

/* ---------------------------------------------------
 * 5.2.6 Cubes & Boxes (https://3dtransforms.desandro.com/box)
 * ---------------------------------------------------*/
.cube-notes {
  margin-bottom: 14rem;
}

.cube-scene {
  width: 240px;
  height: 240px;
  perspective: 600px;
  margin: 50px auto;
}

.cube {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
}

.cube-face {
  position: absolute;
  width: 240px;
  height: 240px;
}

.cube-face img {
  width: 100%;
}

.cube-front {
  transform: rotateY(0deg) translateZ(120px);
}
.cube-back {
  transform: rotateY(180deg) translateZ(120px);
}
.cube-bottom {
  transform: rotateX(-90deg) translateZ(120px);
}
.cube-left {
  transform: rotateY(-90deg) translateZ(120px);
}
.cube-right {
  transform: rotateY(90deg) translateZ(120px);
}
.cube-top {
  transform: rotateX(90deg) translateZ(120px);
}

.cube {
  transform: rotateX(-25deg) rotateY(-25deg) rotateZ(10deg);
  transition: transform 2s ease-in-out;
}

.cube:hover {
  transform: rotateX(40deg) rotateY(-215deg) rotateZ(-10deg);
}

#cubes,
#cubes-title {
  /*   display: none; */
}

              
            
!

JS

              
                
              
            
!
999px

Console