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>
    <div class="notification-bar">
        <div class="notification-content">
            <div class="notification-message">
                🎉 Welcome to our winter sale! Get 20% off on all products
                <a href="#" class="notification-link">Shop now</a>
            </div>
            <button class="close-button" aria-label="Close notification">×</button>
        </div>
    </div>
   <!-- Demo content -->
    <div style="padding: 20px; max-width: 800px; margin: 0 auto; font-family: system-ui; line-height: 1.6;">
        <h1>Understanding Bar Popups: A Modern Web Design Essential</h1>
        
        <h2 style="color: #2563eb; margin-top: 24px;">What are Bar Popups?</h2>
        <p>Bar popups, also known as notification bars or banner messages, are horizontal message strips that typically appear at the top or bottom of a webpage. They provide a non-intrusive way to communicate important information to visitors while preserving the main content's accessibility.</p>

        <h2 style="color: #2563eb; margin-top: 24px;">Key Benefits</h2>
        <p>1. <strong>Non-Intrusive Design:</strong> Unlike traditional modal popups, bar notifications don't interrupt the user's browsing experience or require immediate action.</p>
        <p>2. <strong>Improved User Experience:</strong> They remain visible while users browse, allowing them to engage with the message at their convenience.</p>
        <p>3. <strong>Versatile Communication:</strong> Perfect for announcements, promotions, cookie policies, shipping updates, or any site-wide messages.</p>
        <p>4. <strong>Mobile-Friendly:</strong> They adapt seamlessly to different screen sizes without disrupting mobile usability.</p>

        <h2 style="color: #2563eb; margin-top: 24px;">Common Use Cases</h2>
        <p>• Limited-time offers and promotions<br>
        • Important announcements or updates<br>
        • Cookie consent notifications<br>
        • Free shipping thresholds<br>
        • Newsletter signups<br>
        • Emergency alerts or service updates</p>

        <h2 style="color: #2563eb; margin-top: 24px;">Best Practices</h2>
        <p>• Keep messages concise and clear<br>
        • Include a clear call-to-action when needed<br>
        • Provide an obvious way to dismiss the notification<br>
        • Use contrasting colors to ensure readability<br>
        • Consider timing and frequency of displays<br>
        • Ensure the bar doesn't obscure important page elements</p>

        <div style="background: #f8fafc; padding: 20px; border-radius: 8px; margin-top: 24px;">
            <h3 style="color: #2563eb; margin-top: 0;">💡 Pro Tip</h3>
            <p style="margin-bottom: 0;">For maximum effectiveness, combine bar popups with smart targeting and timing. Show relevant messages based on user behavior, location, or browsing history to increase engagement and conversion rates.</p>
        </div>
    </div>
</body>
              
            
!

CSS

              
                .notification-bar {
            position: fixed;
            top: -100px;
            left: 0;
            right: 0;
            background: linear-gradient(90deg, #2563eb, #3b82f6);
            color: white;
            padding: 16px;
            text-align: center;
            transition: transform 0.3s ease-in-out;
            z-index: 1000;
            display: flex;
            justify-content: center;
            align-items: center;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .notification-bar.show {
            transform: translateY(100px);
        }

        .notification-content {
            max-width: 1200px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 100%;
            font-family: system-ui, -apple-system, sans-serif;
        }

        .notification-message {
            font-size: 15px;
            margin-right: 24px;
        }

        .notification-link {
            color: white;
            text-decoration: underline;
            margin-left: 8px;
        }

        .close-button {
            background: transparent;
            border: none;
            color: white;
            cursor: pointer;
            padding: 4px;
            font-size: 20px;
            line-height: 1;
            opacity: 0.8;
            transition: opacity 0.2s ease;
        }

        .close-button:hover {
            opacity: 1;
        }

        @media (max-width: 768px) {
            .notification-content {
                flex-direction: column;
                gap: 12px;
            }

            .notification-message {
                margin-right: 0;
            }
        }
              
            
!

JS

              
                document.addEventListener('DOMContentLoaded', () => {
            const notificationBar = document.querySelector('.notification-bar');
            const closeButton = document.querySelector('.close-button');
            let isNotificationClosed = false;
            
            // Show notification after a short delay
            setTimeout(() => {
                if (!isNotificationClosed) {
                    notificationBar.classList.add('show');
                }
            }, 1000);

            // Handle close button click
            closeButton.addEventListener('click', () => {
                notificationBar.classList.remove('show');
                isNotificationClosed = true;
            });
        });
              
            
!
999px

Console