Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <div class="bookshelf">
  <div class="book-shelf-frame">
    <div class="book level-4">
      <div class="book-face book-front">To Sir, With Love</div>
      <div class="book-face book-right">To Sir, With Love</div>
      <div class="book-face book-left">To Sir, With Love</div>
      <div class="book-face book-top">To Sir, With Love</div>
    </div>
    <div class="book level-3">
      <div class="book-face book-front">A Wrinkle in Time</div>
      <div class="book-face book-right">A Wrinkle in Time</div>
      <div class="book-face book-left">A Wrinkle in Time</div>
      <div class="book-face book-top">A Wrinkle in Time</div>
    </div>
    <div class="book level-2">
      <div class="book-face book-front">With a Tangled Skein</div>
      <div class="book-face book-right">With a Tangled Skein</div>
      <div class="book-face book-left">With a Tangled Skein</div>
      <div class="book-face book-top">With a Tangled Skein</div>
    </div>
    <div class="book level-1">
      <div class="book-face book-front">The Artifact</div>
      <div class="book-face book-right">The Artifact</div>
      <div class="book-face book-left">The Artifact</div>
      <div class="book-face book-top">The Artifact</div>
      <div class="book-face book-bottom">&nbsp;</div>
    </div>
    <div class="book level-0">
      <div class="book-face book-bottom-shelf">&nbsp;</div>
    </div>
    <div class="shelf hidden"></div>
  </div>
</div>
<div class="page-contents">
  <h3>Sources</h3>
  <p>
    The base for this development effort is in part thanks to 
    <a href="https://3dtransforms.desandro.com" target="kdcNewWin">Intro to CSS 3D Transforms</a> by 
    <a href="https://github.com/desandro/3dtransforms" target="kdcNewWin">David DeSandro</a>.
    Although I completely overhauled and applied all types of modifications, David's examples provided the initial insights.
  </p>
  <p>
    <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/repeating-linear-gradient" target="kdcNewWin">Gradient lines</a> for the edged faces on books is thanks to <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/repeating-linear-gradient" target="kdcNewWin">moz://a's MDN web docs</a>.
  </p>
  <p>
    I originally tried a pseudo <code>:after</code> class for the shelf, but due to perspective incompatibilities, I ended up only using this for the soft blur between books.
    The pseudo class approach I tried was based on this <a href="https://stackoverflow.com/a/25891733/638153" target="kdcNewWin">Stack Overflow: Answer</a> by <a href="https://stackoverflow.com/users/3577849/jme11" target="kdcNewWin">jme11</a> with a <a href="https://www.bootply.com/7h2JKXv40U" target="kdcNewWin">Demo on Bootply</a>
  </p>
</div>

<div class="page-contents">
  <h3>Development Phases</h3>
  <ul>
    <li><a href="https://codepen.io/KeithDC/pen/bGGaRPN" target="kdcNewWin">Bad Shelves</a></li>
    <li><a href="https://codepen.io/KeithDC/pen/bGGaxLe" target="kdcNewWin">Good Shelves</a></li>
    <li><a href="https://codepen.io/KeithDC/pen/WNNdLap" target="kdcNewWin">Narrower Shelves</a></li>
    <li><a href="https://codepen.io/KeithDC/pen/OJJzdVW" target="kdcNewWin">Shelves with Taller Books (latest/most developed)</a></li>
  </ul>
</div>

              
            
!

CSS

              
                :root {
  --book-height: 35px;
  --book-width: 150px;
  --book-width-fix: 200px;
  --book-width-dist-lt: 98px;
  --book-width-dist-rt: 48px;
  --book-depth: 100px;
  --book-depth-sub: -100px;

  --book-color-front: hsl(210, 75%, 50%);
  --book-color-right: hsl(210, 65%, 50%);
  --book-color-left: hsl(215, 65%, 50%);
  --book-color-top: hsl(220, 50%, 50%);
  --book-color-bottom: hsl(210, 50%, 50%);

  --book-color-bottom-shelf: maroon;
}

html, body { height: 98%; }
body { position: relative; }
* { box-sizing: border-box; }

.book-shelf-frame {
  margin: 0 auto;
  padding: 0;
  perspective: 500px;
    height: var(--book-height);
    width: var(--book-width-fix);
  position: fixed;
    bottom: 6rem;
    left: 0;
    right: 0;
} 
  .book {
    background-color: var(--book-color-left);
    cursor: pointer;
    border: none;
    margin: 0;
    outline: none;
    padding: 0;
    position: absolute;
      height: calc(var(--book-height) - 2px);
      width: var(--book-width);
    transform-style: preserve-3d;
  }
    .book.level-0 {
      background: none;
      transform: rotateX(-22deg) rotateY(20deg) rotateZ(4deg) translateX(50px) translateY(0px) translateZ(-80px);
      z-index: 0;
    }
    .book.level-1 {
      transform: rotateX(-22deg) rotateY(20deg) rotateZ(4deg) translateX(0px) translateY(0px) translateZ(0px);
      z-index: 1;
    }
    .book.level-2 {
      bottom: 61px;
      transform: rotateX(-22deg) rotateY(26deg) rotateZ(4deg) translateX(0px) translateY(20px) translateZ(23px);
      z-index: 2;
    }
    .book.level-3 {
      bottom: 97px;
      transform: rotateX(-22deg) rotateY(16deg) rotateZ(4deg) translateX(0px) translateY(20px) translateZ(23px);
      z-index: 3;
    }
    .book.level-4 {
      bottom: 133px;
      transform: rotateX(-22deg) rotateY(22deg) rotateZ(4deg) translateX(0px) translateY(20px) translateZ(23px);
      z-index: 4;
    }
    .book-face {
      color: white;
      margin: 0 auto;
      padding: 0;
      position: absolute;
        height: var(--book-height);
        width: var(--book-width);
      text-align: center;
      vertical-align: middle;
    }
    .book-front {
      border-radius: 7px;
      transform: rotateY( 0deg) translateZ(var(--book-depth));
        height: var(--book-height);
        width: var(--book-width);
    }
    .book-right {
      border-radius: 7px;
      transform: rotateY(90deg) translateX(0px) translateY(1px) translateZ(var(--book-width-dist-rt));
      height: calc(var(--book-height) - 2px);
      width: var(--book-width-fix);
    }
    /* .book-back { } */
    .book-left {
      border-radius: 7px;
      transform: rotateY(-90deg) translateX(0px) translateY(0px) translateZ(var(--book-width-dist-lt));
      height: calc(var(--book-height) - 0px);
      width: calc(var(--book-width-fix));
    }
    .book-top {
      border-radius: 3px;
      transform: rotateX( 90deg) translateZ(100px) translateX(2px);
      height: var(--book-width-fix);
      width: calc(var(--book-width) - 4px);
    }
    .book-bottom {
      transform: rotateX( 90deg) translateZ(66px) translateX(2px) translateY(0px);
      height: var(--book-width-fix);
      width: calc(var(--book-width) - 6px);
      overflow: hidden;
    }
    .book-bottom-shelf {
      transform: rotateX(-90deg) scaleX(2.2) scaleY(1.5) translateX(0px) translateY(50px) translateZ(0px);
      height: var(--book-width-fix);
      width: var(--book-width);
      z-index: 150;
    }

    .book-front { background: var(--book-color-front); }
    .book-right { background: var(--book-color-right); }
    .book-left { background: var(--book-color-left); }
    .book-top { background: var(--book-color-top); }
    .book-bottom { background: var(--book-color-bottom); }
    .book-bottom-shelf { background: var(--book-color-bottom-shelf); }

    .book-front,
    .book-right,
    .book-left,
    .book-top {
      border: 1px dotted #222222;
    }

    .book-front,
    .book-right {
      background-image: repeating-linear-gradient(to bottom,
        rgb(249, 249, 241),
        rgb(204, 202, 173) 10%,
        rgb(100,100,100) 5%);
      color: #000000;
      /*text-shadow: -1px -1px 1px #3aa0c7;*/
    }

    .book-top,
    .book-bottom {
      line-height: calc(var(--book-depth) / 2);
      font-size: calc(var(--book-depth) / 2);
      overflow: hidden;
    }

    .book-front,
    .book-right,
    .book-left {
      font-size: calc(var(--book-height) / 2.5);
      font-weight: 600;
      line-height: var(--book-height);
      vertical-align: bottom;
    }
    .book-front:after {
      background: rgba(200,0,0,.5);
      border-radius: 50%;
      content: '';
      display: block;
      filter: blur(5px);
      height: 3px;
      position: absolute;
      bottom: -5px;
      z-index: -5;
      width: 100%;
    }

  .book-bottom {
    position: relative;
    perspective: 200px;
  }

  .book-bottom-shelf {
    border: 0px solid green;
    position: relative;
    perspective: 200px;
  }
  .book-bottom-shelf:after {
    background: #080868;
    border-radius: 2px;
    content: '';
    position: absolute;
      height: 10px;
      width: var(--book-width);
      top: -10px;
      left: 0px;
      right: 0px;
      z-index: 1;
    transform-style: preserve-3d;
  }

  .book:hover,
  .book:hover .book-front,
  .book:hover .book-left,
  .book:hover .book-top {
    background-color: rgba(100, 50, 25, 0.5);
    
    border: 0px dotted #222222;
    text-shadow: 2px 2px 5px green;
  }

.hidden {
  display: none!important;
}
.page-contents {
  font-family: arial; san-serif;
  font-size: 10px;
}
.page-contents {
  font-family: arial, san-serif;
  font-size: 10px;
  margin: 0 auto;
  outline: 1px dotted gray;
  padding: 0.25rem 0.5rem 0.5rem;
}

/* 
  The basis for this development effort: https://3dtransforms.desandro.com
  Although I completely overhauled and applied all types of modifications,
  many thanks to David DeSandro: https://github.com/desandro/3dtransforms

  Gradient lines for edged faces on books:
  https://developer.mozilla.org/en-US/docs/Web/CSS/repeating-linear-gradient
*/

              
            
!

JS

              
                ;console.clear();

// My first project in a long while with no JavaScript.
              
            
!
999px

Console