About this snippet

Showcase your work with an incredibly realistic 3D hardcover book. We completely rewrote the CSS physics, introducing 3D page edges and non-overshooting easing to guarantee the cover opens and closes flawlessly.

Size
5.4 KB
Uses
HTML, CSS
Loads
Nothing external
Views
380
<div class="book-showcase">
  <div class="hardcover-book">
    
    <!-- The thick block of pages -->
    <div class="pages-block">
      <div class="pages-content">
        <div class="tag">VOL. 01</div>
        <h2>The Archive</h2>
        <p>Step inside this modern 3D portfolio. We built a completely new structure with physical 3D page edges and strict ease-out animations to ensure the cover never clips.</p>
        <button class="btn-primary">Explore Work</button>
      </div>
      
      <!-- Physical 3D edges for the pages -->
      <div class="edge right-edge"></div>
      <div class="edge bottom-edge"></div>
    </div>
    
    <!-- The folding cover -->
    <div class="front-cover">
      <!-- Outside Face -->
      <div class="cover-side cover-outside">
        <div class="cover-design">
          <div class="logo-mark">
            <svg viewBox="0 0 24 24" width="40" height="40" fill="none" stroke="currentColor" stroke-width="1.5"><polygon points="12 2 2 22 22 22"></polygon></svg>
          </div>
          <div class="cover-titles">
            <h1>ARCHIVE</h1>
            <p>INTERACTIVE DESIGN</p>
          </div>
        </div>
      </div>
      
      <!-- Inside Face -->
      <div class="cover-side cover-inside">
        <div class="inside-pattern"></div>
      </div>
    </div>
    
  </div>
</div>
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  margin: 0;
  background: #020617;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.book-showcase {
  perspective: 1600px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hardcover-book {
  position: relative;
  width: 320px;
  height: 450px;
  transform-style: preserve-3d;
  transform: rotateX(30deg) rotateY(-25deg);
  transition: transform 0.6s ease;
  cursor: pointer;
}

.hardcover-book:hover {
  transform: rotateX(15deg) rotateY(-10deg);
}

.pages-block {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #f8fafc;
  border-radius: 2px 8px 8px 2px;
  transform-style: preserve-3d;
  box-shadow: inset 10px 0 20px rgba(0,0,0,0.1), 10px 10px 30px rgba(0,0,0,0.5);
}

.pages-content {
  padding: 40px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #0f172a;
}

.tag {
  font-size: 0.85rem;
  font-weight: 700;
  color: #3b82f6;
  letter-spacing: 2px;
  margin-bottom: 20px;
}

.pages-content h2 {
  font-size: 2.2rem;
  margin: 0 0 16px 0;
  line-height: 1.1;
  letter-spacing: -1px;
}

.pages-content p {
  color: #475569;
  line-height: 1.6;
  margin-bottom: 40px;
}

.btn-primary {
  align-self: flex-start;
  background: #0f172a;
  color: #ffffff;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #3b82f6;
}

/* Constructing the physical thickness of the pages */
.edge {
  position: absolute;
  background: #e2e8f0;
  /* Striped background to mimic individual pages of paper */
  background-image: repeating-linear-gradient(to bottom, #e2e8f0 0px, #e2e8f0 2px, #cbd5e1 2px, #cbd5e1 3px);
}

.right-edge {
  top: 4px;
  right: 0;
  width: 20px;
  height: calc(100% - 8px);
  transform-origin: right center;
  transform: rotateY(90deg);
}

.bottom-edge {
  bottom: 0;
  left: 4px;
  width: calc(100% - 8px);
  height: 20px;
  transform-origin: bottom center;
  transform: rotateX(-90deg);
  background-image: repeating-linear-gradient(to right, #e2e8f0 0px, #e2e8f0 2px, #cbd5e1 2px, #cbd5e1 3px);
}

/* The Cover Logic */
.front-cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
  /* Sit directly on top of the 20px thick pages */
  transform: translateZ(21px);
  /* CRITICAL FIX: The cubic-bezier 0.2, 0.8, 0.2, 1 guarantees NO OVERSHOOT when returning to 0 */
  transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 10;
}

.hardcover-book:hover .front-cover {
  transform: translateZ(21px) rotateY(-160deg);
}

/* Dual-sided cover geometry */
.cover-side {
  position: absolute;
  top: -2px;
  left: -2px;
  /* Slightly larger than pages for hardcover overhang */
  width: calc(100% + 6px);
  height: calc(100% + 4px);
  border-radius: 4px 12px 12px 4px;
  backface-visibility: hidden;
}

.cover-outside {
  background: #0f172a;
  color: #ffffff;
  box-shadow: inset 8px 0 20px rgba(0,0,0,0.8), 5px 5px 15px rgba(0,0,0,0.5);
  border-left: 2px solid #1e293b;
  transform: translateZ(1px);
}

.cover-design {
  padding: 40px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), transparent);
}

.logo-mark {
  color: #3b82f6;
}

.cover-titles h1 {
  font-size: 3rem;
  margin: 0;
  letter-spacing: 4px;
}

.cover-titles p {
  margin: 10px 0 0 0;
  color: #94a3b8;
  letter-spacing: 2px;
  font-size: 0.9rem;
}

.cover-inside {
  background: #1e293b;
  transform: rotateY(180deg) translateZ(1px);
  box-shadow: inset -8px 0 20px rgba(0,0,0,0.8);
  display: flex;
  justify-content: center;
  align-items: center;
}

.inside-pattern {
  width: 80%;
  height: 80%;
  border: 1px solid rgba(255,255,255,0.05);
  background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 10px 10px;
}
Esc
↑↓ moveEnter select

Start from a template

Open an .html file, or HTML, CSS, JS, Markdown, Less or TypeScript files. You can also drop them here. Styles and scripts go into their panes.

Share

Source

Keyboard shortcuts

Save