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

              
                <body>
    <button class="trigger-button" onclick="showPopup()">Show Special Offer</button>

    <div class="overlay" id="overlay">
        <div class="popup" id="popup">
            <div class="decorative-shape shape-1"></div>
            <div class="decorative-shape shape-2"></div>
            <div class="discount-badge">Limited Time!</div>
            <button class="close-button" onclick="hidePopup()">&times;</button>
            <div class="popup-content">
                <h2>Get 20% Off Your First Order</h2>
                <p>Join our exclusive community today and unlock your special discount code. Be the first to know about new releases, special promotions, and insider tips!</p>
                <form id="leadForm" onsubmit="handleSubmit(event)">
                    <div class="form-group">
                        <label for="name">Full Name</label>
                        <input type="text" id="name" required placeholder="Enter your name">
                    </div>
                    <div class="form-group">
                        <label for="email">Email Address</label>
                        <input type="email" id="email" required placeholder="Enter your email">
                    </div>
                    <button type="submit" class="submit-button">Claim My 20% Discount</button>
                </form>
            </div>
        </div>
    </div>
</body>
              
            
!

CSS

              
                      :root {
            --primary-gradient: linear-gradient(135deg, #4F46E5, #7C3AED);
            --secondary-gradient: linear-gradient(135deg, #3B82F6, #2563EB);
            --text-color: #1F2937;
            --bg-color: #F3F4F6;
        }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            margin: 0;
            padding: 20px;
            min-height: 100vh;
            background-color: var(--bg-color);
            background-image: 
                radial-gradient(circle at 20% 20%, rgba(79, 70, 229, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(124, 58, 237, 0.1) 0%, transparent 50%);
        }

        .trigger-button {
            padding: 14px 28px;
            background-image: var(--primary-gradient);
            color: white;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 600;
            transition: all 0.3s;
            box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
        }

        .trigger-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
        }

        .overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.6);
            backdrop-filter: blur(6px);
            z-index: 1000;
            animation: fadeIn 0.3s ease-out;
        }

        .popup {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) scale(0.7);
            background: white;
            padding: 40px;
            border-radius: 24px;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
            width: 90%;
            max-width: 480px;
            z-index: 1001;
            opacity: 0;
            transition: all 0.3s ease-out;
            background-image: 
                radial-gradient(circle at 0% 0%, rgba(79, 70, 229, 0.03) 0%, transparent 50%),
                radial-gradient(circle at 100% 100%, rgba(124, 58, 237, 0.03) 0%, transparent 50%);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .popup.active {
            transform: translate(-50%, -50%) scale(1);
            opacity: 1;
        }

        .close-button {
            position: absolute;
            top: 20px;
            right: 20px;
            background: rgba(243, 244, 246, 0.8);
            border: none;
            font-size: 20px;
            cursor: pointer;
            color: #6B7280;
            padding: 8px;
            line-height: 1;
            border-radius: 50%;
            width: 36px;
            height: 36px;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .close-button:hover {
            background: rgba(243, 244, 246, 1);
            color: #374151;
            transform: rotate(90deg);
        }

        .popup-content {
            position: relative;
        }

        .popup-content h2 {
            margin: 0 0 12px 0;
            color: var(--text-color);
            font-size: 28px;
            font-weight: 700;
            background: var(--primary-gradient);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            line-height: 1.2;
        }

        .popup-content p {
            margin: 0 0 32px 0;
            color: #4B5563;
            font-size: 16px;
            line-height: 1.6;
        }

        .form-group {
            margin-bottom: 24px;
            position: relative;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            color: var(--text-color);
            font-weight: 500;
            font-size: 14px;
        }

        .form-group input {
            width: 100%;
            padding: 14px 16px;
            border: 2px solid #E5E7EB;
            border-radius: 12px;
            font-size: 16px;
            transition: all 0.3s;
            box-sizing: border-box;
            background: #F9FAFB;
        }

        .form-group input:focus {
            outline: none;
            border-color: #4F46E5;
            background: white;
            box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
        }

        .submit-button {
            width: 100%;
            padding: 16px;
            background-image: var(--primary-gradient);
            color: white;
            border: none;
            border-radius: 12px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
            box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
            position: relative;
            overflow: hidden;
        }

        .submit-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(79, 70, 229, 0.3);
        }

        .submit-button::after {
            content: '';
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: linear-gradient(
                45deg,
                transparent 0%,
                rgba(255, 255, 255, 0.1) 50%,
                transparent 100%
            );
            transform: rotate(45deg);
            transition: transform 0.5s;
        }

        .submit-button:hover::after {
            transform: rotate(45deg) translate(50%, 50%);
        }

        .discount-badge {
            position: absolute;
            top: -15px;
            right: -15px;
            background: linear-gradient(135deg, #FF6B6B, #FF8E53);
            color: white;
            padding: 8px 16px;
            border-radius: 20px;
            font-weight: 600;
            font-size: 14px;
            box-shadow: 0 4px 12px rgba(255, 107, 107, 0.2);
            transform: rotate(12deg);
        }

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        @keyframes slideUp {
            from { transform: translateY(20px); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }

        .form-group {
            animation: slideUp 0.5s ease-out forwards;
            opacity: 0;
        }

        .form-group:nth-child(1) { animation-delay: 0.2s; }
        .form-group:nth-child(2) { animation-delay: 0.3s; }

        @media (max-width: 640px) {
            .popup {
                padding: 32px;
                width: 95%;
            }

            .popup-content h2 {
                font-size: 24px;
            }
        }

        /* Decorative elements */
        .decorative-shape {
            position: absolute;
            width: 80px;
            height: 80px;
            border-radius: 50%;
            background: linear-gradient(45deg, rgba(79, 70, 229, 0.1), rgba(124, 58, 237, 0.1));
            z-index: -1;
        }

        .shape-1 {
            top: -20px;
            left: -20px;
        }

        .shape-2 {
            bottom: -20px;
            right: -20px;
            background: linear-gradient(45deg, rgba(59, 130, 246, 0.1), rgba(37, 99, 235, 0.1));
        }
              
            
!

JS

              
                     function showPopup() {
            const overlay = document.getElementById('overlay');
            const popup = document.getElementById('popup');
            overlay.style.display = 'block';
            setTimeout(() => {
                popup.classList.add('active');
            }, 10);
        }

        function hidePopup() {
            const overlay = document.getElementById('overlay');
            const popup = document.getElementById('popup');
            popup.classList.remove('active');
            setTimeout(() => {
                overlay.style.display = 'none';
            }, 300);
        }

        function handleSubmit(event) {
            event.preventDefault();
            const name = document.getElementById('name').value;
            const email = document.getElementById('email').value;
            
            // Here you would typically send the data to your server
            console.log('Form submitted:', { name, email });
            
            // Show success message (in production, you'd want to wait for server response)
            alert('Thank you for subscribing! Your discount code will be sent to your email.');
            hidePopup();
        }

        // Optional: Show popup after X seconds
        // setTimeout(showPopup, 5000);
              
            
!
999px

Console