Interactive Example

Free Buttons

Interactive buttons with a click counter and simple animations.

Live preview

Open preview in a new tab (new tab)

Code

HTML
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Interactive Example</title>
</head>
<body>
    <div class="container">
        <h1>Interactive Elements</h1>
        <p>Try clicking the buttons below:</p>
        
        <div class="button-group">
            <button id="colorBtn" class="btn">Change Color</button>
            <button id="textBtn" class="btn">Change Text</button>
            <button id="resetBtn" class="btn">Reset</button>
        </div>
        
        <div id="output" class="output">
            <p>This text will change based on your interactions.</p>
        </div>
    </div>
</body>
</html>
CSS
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    margin: 0;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

h1 {
    color: #4f46e5;
    margin-bottom: 20px;
}

.button-group {
    display: flex;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.btn {
    background-color: #4f46e5;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
}

.btn:hover {
    background-color: #4338ca;
    transform: translateY(-2px);
}

.output {
    margin-top: 30px;
    padding: 20px;
    background-color: #f8fafc;
    border-radius: 8px;
    border-left: 4px solid #4f46e5;
    min-height: 100px;
}

.color-change {
    background-color: #e0f2fe !important;
    color: #0369a1 !important;
}

@media (max-width: 600px) {
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}
JavaScript
document.addEventListener('DOMContentLoaded', function() {
    const colorBtn = document.getElementById('colorBtn');
    const textBtn = document.getElementById('textBtn');
    const resetBtn = document.getElementById('resetBtn');
    const output = document.getElementById('output');
    
    colorBtn.addEventListener('click', function() {
        output.classList.toggle('color-change');
        output.innerHTML = '<p>Background color changed!</p>';
    });
    
    textBtn.addEventListener('click', function() {
        const texts = [
            '<p>You clicked the text button!</p>',
            '<p>This is new content generated by JavaScript.</p>',
            '<p>JavaScript makes web pages interactive.</p>',
            '<p>You can create dynamic content with JS.</p>'
        ];
        const randomText = texts[Math.floor(Math.random() * texts.length)];
        output.innerHTML = randomText;
    });
    
    resetBtn.addEventListener('click', function() {
        output.classList.remove('color-change');
        output.innerHTML = '<p>This text will change based on your interactions.</p>';
    });
});
Buttons
Free

Gradient Button

Beautiful gradient buttons with hover animations

  • HTML
  • CSS
Buttons
Cards
Free

Modal Dialog

Elegant modal for confirmations and alerts

  • HTML
  • CSS
  • JavaScript
Cards
Navigation
Free

Navigation Example

A responsive navigation bar with a logo, menu links and a mobile toggle.

  • HTML
  • CSS
  • JavaScript
Navigation