پیش‌نمایش زنده
کد HTML
<div class="wrapper">
  <div class="printer"></div>

  <div class="printer-display">
    <span class="printer-message"> Click to print</span>
    <div class="letter-wrapper">
      <span class="letter">P</span>
      <span class="letter">r</span>
      <span class="letter">i</span>
      <span class="letter">n</span>
      <span class="letter">t</span>
      <span class="letter">i</span>
      <span class="letter">n</span>
      <span class="letter">g</span>
      <span class="letter">.</span>
      <span class="letter">.</span>
      <span class="letter">.</span>
    </div>
  </div>

  <button class="print-button">🖨</button>

  <div class="receipt-wrapper">
    <div class="receipt">
      <div class="receipt-header">
        Shop Name <br />
        Address 123, <br />
        City, State, <br />
        ZIP Code
        <div class="logo">👕</div>
      </div>
      <div class="receipt-subheader">
        Order No. #001234 <br />
        2025-01-01 - 11:48
      </div>
      <table class="receipt-table">
        <tbody>
          <tr>
            <th>Item</th>
            <th>Qty</th>
            <th>Price</th>
          </tr>
          <tr>
            <td>First item</td>
            <td>1 x</td>
            <td>5.99</td>
          </tr>
          <tr>
            <td>Second item</td>
            <td>1 x</td>
            <td>21.49</td>
          </tr>
          <tr>
            <td>Third item</td>
            <td>2 x</td>
            <td>6.20</td>
          </tr>
          <tr>
            <td>Fourth item</td>
            <td>1 x</td>
            <td>3.79</td>
          </tr>
          <tr>
            <td>Fifth item</td>
            <td>5 x</td>
            <td>1.29</td>
          </tr>
          <tr class="receipt-subtotal">
            <td colspan="2">Subtotal</td>
            <td>50.12</td>
          </tr>

          <tr class="receipt-tax">
            <td colspan="2">Tax (13%)</td>
            <td>6.52</td>
          </tr>
          <tr class="receipt-total">
            <td colspan="2">Total</td>
            <td>56.64</td>
          </tr>
        </tbody>
      </table>
      <div class="receipt-message">Thank you!</div>
    </div>
  </div>
</div>
کد CSS
.wrapper {
  --printer-color: #dcdac4;
  --printer-color-2: #c0beaa;
  --receipt-color: #f5f5f5;

  font-size: 14px;
  position: relative;
  user-select: none;
}

.printer {
  width: 320px;
  height: 80px;
  border-radius: 0 0 8px 8px;

  background-color: var(--printer-color);
  background-image: url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WUKP2q+k7RdsxyOB11n0xtOvnW4irMMFNV4H0uqwS5ExsmP9AxbDTc9JwgneAT5vTiUSm1E7BSflSt3bfa1tv8Di3R8n3Af7MNWzs49hmauE2wP+ttrq+AsWpFG2awvsuOqbipWHgtuvuaAE+A1Z/7gC9hesnr+7wqCwG8c5yAg3AL1fm8T9AZtp/bbJGwl1pNrE7RuOX7PeMRUERVaPpEs+yqeoSmuOlokqw49pgomjLeh7icHNlG19yjs6XXOMedYm5xH2YxpV2tc0Ro2jJfxC50ApuxGob7lMsxfTbeUv07TyYxpeLucEH1gNd4IKH2LAg5TdVhlCafZvpskfncCfx8pOhJzd76bJWeYFnFciwcYfubRc12Ip/ppIhA1/mSZ/RxjFDrJC5xifFjJpY2Xl5zXdguFqYyTR1zSp1Y9p+tktDYYSNflcxI0iyO4TPBdlRcpeqjK/piF5bklq77VSEaA+z8qmJTFzIWiitbnzR794USKBUaT0NTEsVjZqLaFVqJoPN9ODG70IPbfBHKK+/q/AWR0tJzYHRULOa4MP+W/HfGadZUbfw177G7j/OGbIs8TahLyynl4X4RinF793Oz+BU0saXtUHrVBFT/DnA3ctNPoGbs4hRIjTok8i+algT1lTHi4SxFvONKNrgQFAq2/gFnWMXgwffgYMJpiKYkmW3tTg3ZQ9Jq+f8XN+A5eeUKHWvJWJ2sgJ1Sop+wwhqFVijqWaJhwtD8MNlSBeWNNWTa5Z5kPZw5+LbVT99wqTdx29lMUH4OIG/D86ruKEauBjvH5xy6um/Sfj7ei6UUVk4AIl3MyD4MSSTOFgSwsH/QJWaQ5as7ZcmgBZkzjjU1UrQ74ci1gWBCSGHtuV1H2mhSnO3Wp/3fEV5a+4wz//6qy8JxjZsmxxy5+4w9CDNJY09T072iKG0EnOS0arEYgXqYnXcYHwjTtUNAcMelOd4xpkoqiTYICWFq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==);
  border: 2px solid var(--printer-color-2);
  box-shadow:
    0 16px 32px 0px #0002,
    0 -30px 16px 0px #0001;
}

.printer::before {
  content: "";
  position: absolute;
  top: -30px;
  left: 0;
  width: 100%;
  height: 70px;
  border-radius: 12px 12px 0 0;
  border-bottom: 2px solid #0003;
  box-shadow:
    0 12px 16px -12px #fff5 inset,
    0 -6px 16px -6px #0003 inset,
    0 6px 8px -6px #0004;
  box-sizing: border-box;
  background-color: inherit;
  background-image: inherit;
  filter: brightness(1.12);
  z-index: 2;
}

.printer::after {
  content: "";
  position: absolute;
  top: 20px;
  left: 30px;
  width: 260px;
  height: 40px;
  border-radius: 0 0 4px 4px;
  border-bottom: 1px solid #0003;
  background-color: inherit;
  background-image: linear-gradient(
    to top,
    var(--printer-color),
    60%,
    var(--printer-color-2)
  );
  box-shadow: 0 4px 4px -2px #0004;

  z-index: 1;
}

.printer-display {
  z-index: 2;

  display: flex;
  padding: 6px 8px;
  position: absolute;
  top: -10px;
  left: 30px;
  width: 160px;
  height: 32px;

  background-color: #000;
  background-image: linear-gradient(transparent 0, #fff2 90%, transparent 100%);
  background-size: 100% 8px;
  background-repeat: no-repeat;
  border: 3px solid var(--printer-color-2);
  border-radius: 6px;
  box-sizing: border-box;
  box-shadow:
    -1px -1px 2px 0 #fff9 inset,
    1px 1px 5px 1px #000 inset,
    0 0 1px 2px #0002;

  font-family: "Courier New", Courier, monospace;
  font-size: 0.8em;
  color: #5aff5a;
  filter: drop-shadow(1px 1px 1px #0002);
}

.print-button {
  z-index: 2;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  position: absolute;
  top: -30px;
  right: 0;
  margin: 16px;
  border: 1px solid #0001;
  border-radius: 6px;
  width: 48px;
  height: 36px;
  background-color: var(--printer-color);
  box-shadow:
    1px 1px 2px 0 #fff8 inset,
    -1px -1px 2px 0 #0002 inset,
    0 2px 6px 0px #0002;
  transition:
    box-shadow 0.1s ease-in-out,
    transform 0.1s ease-in-out;
}

.print-button:hover {
  box-shadow:
    2px 2px 2px 0 #fff9 inset,
    -2px -2px 2px 0 #0002 inset,
    0 2px 10px 0px #0002;
  transform: scale(1.05);
}
.print-button:active {
  box-shadow:
    2px 2px 2px 0 #0002 inset,
    -2px -2px 2px 0 #fff9 inset,
    0 0px 4px 0px #fff9;
  transform: scale(0.95);
}

.receipt-wrapper {
  position: absolute;
  top: 0;
  left: 44px;
  filter: drop-shadow(0 0 12px #0001);
}

.receipt {
  z-index: 2;
  position: relative;

  display: flex;
  flex-direction: column;
  gap: 1em;

  padding: 16px;
  width: 200px;
  min-height: 160px;

  font-size: 0.75em;
  font-family: "Azeret Mono", "Roboto Mono", monospace;
  font-weight: 400;
  color: #444;

  background-color: var(--receipt-color);
  box-shadow:
    0 12px 12px 0 #0001,
    0 24px 24px 0 #0001,
    0 36px 36px 0 #0001;
}

.receipt::before,
.receipt::after {
  --angle: 45deg;

  content: "";
  display: block;
  position: absolute;
  left: 0px;
  width: 100%;
  height: 8px;

  background: linear-gradient(
      calc(var(--angle) * -1),
      var(--receipt-color) 4px,
      transparent 0
    ),
    linear-gradient(var(--angle), var(--receipt-color) 4px, transparent 0);
  background-position: 4px 0;
  background-repeat: repeat-x;
  background-size: 8px 8px;
}
.receipt::before {
  top: -8px;
  background-position: 4px 0;
}
.receipt::after {
  bottom: -8px;
  background-position: 0 100%;
  --angle: 225deg;
}

.receipt-header,
.receipt-subheader,
.receipt-message {
  display: flex;
  justify-content: space-between;
  padding: 0.2em 0;
}

.receipt-header {
  font-size: 1.1em;
  font-weight: 600;
}
.receipt-subheader {
  border-bottom: 1px dashed #ccc;
}
.receipt-message {
  justify-content: center;
  text-align: center;
  padding: 0 1em;
}

.receipt .logo {
  width: 48px;
  font-size: 3em;
  transform: rotate(10deg);
  filter: grayscale(1);
}

.receipt-subtotal td {
  border-top: 1px dashed #ccc;
}

.receipt-total td {
  border-top: 1px dashed #ccc;
  font-weight: 600;
}

.receipt-table {
  font: inherit;
  color: inherit;
  text-align: left;
  line-height: 1.5em;

  th:last-child,
  td:last-child {
    text-align: right;
  }
  td:last-child::after {
    content: " $";
  }
}

.receipt-wrapper {
  transform: translateY(-100%);
  clip-path: inset(100% -100px -100px -100px);
  transition: clip-path 0.5s;
}

.letter-wrapper {
  position: inherit;
  display: flex;
}

.letter {
  display: inline-block;
  opacity: 0;
}

.wrapper:has(.print-button:focus) {
  .receipt-wrapper {
    animation:
      print 1.2s 1 forwards ease-in,
      display 0.4s 1 forwards cubic-bezier(0, 0.63, 0.96, 1.1);
    animation-delay: 0s, 1.35s;
  }

  .printer-message {
    opacity: 0;
  }

  .letter:nth-child(1) {
    animation-delay: 0.05s;
  }
  .letter:nth-child(2) {
    animation-delay: 0.1s;
  }
  .letter:nth-child(3) {
    animation-delay: 0.15s;
  }
  .letter:nth-child(4) {
    animation-delay: 0.2s;
  }
  .letter:nth-child(5) {
    animation-delay: 0.25s;
  }
  .letter:nth-child(6) {
    animation-delay: 0.3s;
  }
  .letter:nth-child(7) {
    animation-delay: 0.35s;
  }
  .letter:nth-child(8) {
    animation-delay: 0.4s;
  }
  .letter:nth-child(9) {
    animation-delay: 0.45s;
  }
  .letter:nth-child(10) {
    animation-delay: 0.5s;
  }
  .letter:nth-child(11) {
    animation-delay: 0.55s;
  }
  .letter:nth-child(12) {
    animation-delay: 0.6s;
  }

  .letter {
    animation: show-text 0.6s 1 forwards linear;
  }
}

@keyframes print {
  100% {
    transform: translateY(10%);
    clip-path: inset(-20% -100px -100px -100px);
  }
}

@keyframes display {
  30% {
    transform: translateY(22%) rotate3d(1, 0, 1, -5deg);
  }
  70% {
    z-index: 5;
  }
  100% {
    z-index: 5;
    transform: translateY(-40%) scale(1.2);
  }
}

@keyframes show-text {
  10%,
  100% {
    opacity: 1;
  }
}
نوع: card
تاریخ ایجاد: 2026/06/06
آخرین بروزرسانی: 2026/06/06