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="container px-4 py-5" id="custom-cards">
    <h2 class="pb-2 border-bottom">Show Up Phone</h2>

    <div class="row row-cols-1 row-cols-lg-3 align-items-stretch g-4 py-5">
      <div class="col">
        <div class="displayP card card-cover h-100 overflow-hidden text-bg-dark rounded-4 shadow-lg" style="background-image: url('https://img.freepik.com/free-photo/side-view-man-using-smartphone_23-2148793481.jpg');" data-toshow="3,9,7,8,6,5,3">
          <div class="d-flex flex-column h-100 p-5 pb-3 text-white text-shadow-1">
            <h2 class="display-5">Orders:</h2>
            <h3 class="pt-5 mt-5 mb-4 display-6 lh-1 fw-bold block-heading">33X-XXX-XXX</h3>
            <ul class="d-flex list-unstyled mt-auto">
              <li class="me-auto">
                <i class="bi bi-phone-vibrate display-5"></i>
              </li>
              <li class="d-flex align-items-center">
                <i class="bi me-2 bi-calendar3"></i>
                <small>9AM - 7PM</small>
              </li>
            </ul>
          </div>
        </div>
      </div>

      <div class="col">
        <div class="displayP card card-cover h-100 overflow-hidden text-bg-dark rounded-4 shadow-lg" style="background-image: url('https://img.freepik.com/free-photo/female-doing-video-call_181624-44456.jpg');" data-toshow="9, 8,7,6,5,4,3">
          <div class="d-flex flex-column h-100 p-5 pb-3 text-white text-shadow-1">
            <h2 class="display-5">Support:</h2>
            <h3 class="pt-5 mt-5 mb-4 display-6 lh-1 fw-bold block-heading">82X-XXX-XXX</h3>
            <ul class="d-flex list-unstyled mt-auto">
              <li class="me-auto">
                <i class="bi bi-telephone-inbound display-5"></i>
              </li>
              <li class="d-flex align-items-center me-3">
                <i class="bi me-2 bi-globe-europe-africa"></i>
                <small>Europe</small>
              </li>
              <li class="d-flex align-items-center">
                <i class="bi me-2 bi-stopwatch"></i>
                <small>24h</small>
              </li>
            </ul>
          </div>
        </div>
      </div>

      <div class="col">
        <div class="displayP card card-cover h-100 overflow-hidden text-bg-dark rounded-4 shadow-lg" style="background-image: url('https://img.freepik.com/free-photo/digital-technology-internet-play-display-contact_1421-363.jpg');" data-toshow="2,3,4,5,3,7,3">
          <div class="d-flex flex-column h-100 p-5 pb-3 text-shadow-1">
            <h2 class="display-5">HR:</h2>
            <h3 class="pt-5 mt-5 mb-4 display-6 lh-1 fw-bold block-heading">74X-XXX-XXX</h3>
            <ul class="d-flex list-unstyled mt-auto">
              <li class="me-auto">
                <i class="bi bi-phone-vibrate display-5"></i>
              </li>
              <li class="d-flex align-items-center">
                <i class="bi me-2 bi-calendar3"></i>
                <small>9AM - 4PM</small>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
              
            
!

CSS

              
                .feature-icon {
  width: 4rem;
  height: 4rem;
  border-radius: .75rem;
}

.icon-square {
  width: 3rem;
  height: 3rem;
  border-radius: .75rem;
}

.text-shadow-1 { text-shadow: 0 .125rem .25rem rgba(0, 0, 0, .25); }
.text-shadow-2 { text-shadow: 0 .25rem .5rem rgba(0, 0, 0, .25); }
.text-shadow-3 { text-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, .25); }

.card-cover {
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
}

.feature-icon-small {
  width: 3rem;
  height: 3rem;
}
body {
  background-color: #12091A;
}
body * {
  color: #FFF;
}
              
            
!

JS

              
                document.addEventListener("DOMContentLoaded", function () {
    let isAnimating = false;

    function animateNumber(element, targetNumber, callback) {
        let currentNumber = 0;
        let interval = setInterval(() => {
            element.textContent = currentNumber;
            if (currentNumber === targetNumber) {
                clearInterval(interval);
                callback();
            } else {
                currentNumber++;
            }
        }, 50);
    }

    function displayP(event) {
        if (isAnimating) return;
        isAnimating = true;

        let card = event.currentTarget;
        let phoneElement = card.querySelector('.block-heading');

        if (!phoneElement) {
            isAnimating = false;
            return;
        }

        let defaultP = phoneElement.getAttribute("data-default") || phoneElement.textContent;
        phoneElement.setAttribute("data-default", defaultP);
        let isRevealed = phoneElement.getAttribute("data-revealed") === "true";

        let hiddenPhone = card.getAttribute("data-toshow")?.split(',') || [];
        if (hiddenPhone.length === 0) {
            console.error("Brak danych w atrybucie data-toshow dla tej karty.");
            isAnimating = false;
            return;
        }

        if (isRevealed) {
            phoneElement.textContent = defaultP;
            phoneElement.setAttribute("data-revealed", "false");
            isAnimating = false;
        } else {
            phoneElement.innerHTML = '';
            let hiddenIndex = 0;

            function revealNextDigit(index) {
                if (index >= defaultP.length) {
                    phoneElement.setAttribute("data-revealed", "true");
                    isAnimating = false;
                    return;
                }

                if (defaultP[index] === 'X' && hiddenIndex < hiddenPhone.length) {
                    let targetDigit = parseInt(hiddenPhone[hiddenIndex]);
                    let span = document.createElement('span');
                    span.textContent = "0";

                    animateNumber(span, targetDigit, () => {
                        span.textContent = targetDigit;
                        hiddenIndex++;
                        revealNextDigit(index + 1);
                    });

                    phoneElement.appendChild(span);
                } else {
                    phoneElement.appendChild(document.createTextNode(defaultP[index]));
                    revealNextDigit(index + 1);
                }
            }

            revealNextDigit(0);
        }
    }

    // Dodanie nasłuchiwania zdarzeń
    document.querySelectorAll('.displayP').forEach(card => {
        card.addEventListener('click', displayP);
    });
});
              
            
!
999px

Console