[X(A)] Dynamic Progress Bar Generator

Dynamic Progress Bar Generator

Dynamic Bar Width App

75%

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dynamic Progress Bar Generator</title>
    <style>
        body {
            font-family: sans-serif;
            background-color: #f4f7f6;
            padding: 40px;
            display: flex;
            justify-content: center;
        }

        .app-card {
            background: #fff;
            padding: 24px;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
            width: 100%;
            max-width: 400px;
        }

        h2 {
            margin-top: 0;
            font-size: 1.2rem;
            color: #333;
        }

        .input-group {
            margin-bottom: 16px;
        }

        label {
            display: block;
            margin-bottom: 6px;
            font-size: 0.9rem;
            color: #666;
        }

        input {
            width: 100%;
            padding: 8px 12px;
            box-sizing: border-box;
            border: 1px solid #ccc;
            border-radius: 6px;
            font-size: 1rem;
        }

        button {
            background-color: #007bff;
            color: #white;
            color: white;
            border: none;
            padding: 10px 16px;
            width: 100%;
            border-radius: 6px;
            font-size: 1rem;
            cursor: pointer;
            font-weight: 600;
        }

        button:hover {
            background-color: #0056b3;
        }

        .preview-area {
            margin-top: 24px;
            border-top: 1px solid #eee;
            padding-top: 16px;
        }

        /* Reusing your exact CSS classes */
        .bar-container {
            background-color: #eee;
            border-radius: 6px;
            overflow: hidden;
            height: 16px;
            width: 100%;
        }

        .bar-fill {
            height: 100%;
            text-align: right;
            padding-right: 4px;
            color: #fff;
            font-size: 0.8em;
            line-height: 16px;
            border-radius: 6px;
            background-color: #28a745;
            transition: width 0.4s ease; /* Smooth animation when width changes */
        }
    </style>
</head>
<body>

    <div class="app-card">
        <h2>Dynamic Bar Width App</h2>
       
        <div class="input-group">
            <label for="widthInput">Enter Width Percentage (0 - 100):</label>
            <input type="number" id="widthInput" min="0" max="100" value="75">
        </div>

        <button onclick="updateBar()">Generate Bar</button>

        <div class="preview-area">
            <label style="margin-bottom: 8px;">Live Preview:</label>
            <div class="bar-container" id="barContainer" title="75%">
                <div class="bar-fill" id="barFill" style="width: 75%;">75%</div>
            </div>
        </div>
    </div>

    <script>
        function updateBar() {
            const inputVal = document.getElementById('widthInput').value;
            const barFill = document.getElementById('barFill');
            const barContainer = document.getElementById('barContainer');

            // Validate input between 0 and 100
            let percentage = Number(inputVal);
            if (percentage < 0) percentage = 0;
            if (percentage > 100) percentage = 100;

            // Update the width style and inner text dynamically via JavaScript
            barFill.style.width = percentage + '%';
            barFill.textContent = percentage + '%';
           
            // Update the HTML title attribute for hover tooltips
            barContainer.setAttribute('title', percentage + '%');
        }
    </script>

</body>
</html>

Comments

Popular posts from this blog

[MAIN PROGRAM] UNDONE HOUSEHOLD WORKs WEB-PROGRAM v2/MAIN

PENDING ITEMs [REVISION] v0