Skip to content

samukelo2604/Margin-calculator2v

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

<title>Business Margin Calculator</title> <style> :root { --primary-blue: #2563eb; --success-green: #16a34a; --bg-dark: #0f172a; --card-bg: #1e293b; --text-light: #f8fafc; }
    body {
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        background-color: var(--bg-dark);
        color: var(--text-light);
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        margin: 0;
    }

    .calculator-card {
        background-color: var(--card-bg);
        padding: 2rem;
        border-radius: 12px;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
        width: 90%;
        max-width: 400px;
    }

    h2 {
        text-align: center;
        color: var(--primary-blue);
        margin-bottom: 1.5rem;
    }

    .input-group {
        margin-bottom: 1.2rem;
    }

    label {
        display: block;
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
        color: #94a3b8;
    }

    input {
        width: 100%;
        padding: 10px;
        border-radius: 6px;
        border: 1px solid #334155;
        background-color: #0f172a;
        color: white;
        font-size: 1rem;
        box-sizing: border-box;
    }

    button {
        width: 100%;
        padding: 12px;
        background-color: var(--primary-blue);
        color: white;
        border: none;
        border-radius: 6px;
        font-weight: bold;
        cursor: pointer;
        transition: background 0.3s;
    }

    button:hover {
        background-color: #1d4ed8;
    }

    .results {
        margin-top: 1.5rem;
        padding-top: 1rem;
        border-top: 1px solid #334155;
    }

    .result-item {
        display: flex;
        justify-content: space-between;
        margin-bottom: 0.5rem;
    }

    .highlight {
        color: var(--success-green);
        font-weight: bold;
    }
</style>

Margin Calculator (ZAR)

<div class="input-group">
    <label for="cost">Cost Price (R)</label>
    <input type="number" id="cost" placeholder="450">
</div>

<div class="input-group">
    <label for="selling">Selling Price (R)</label>
    <input type="number" id="selling" placeholder="650">
</div>

<button onclick="calculate()">Calculate Profit</button>

<div class="results" id="resultsArea" style="display:none;">
    <div class="result-item">
        <span>Gross Profit:</span>
        <span id="grossProfit" class="highlight">R0.00</span>
    </div>
    <div class="result-item">
        <span>Margin Percentage:</span>
        <span id="marginPercent" class="highlight">0%</span>
    </div>
</div>
<script> function calculate() { const cost = parseFloat(document.getElementById('cost').value); const selling = parseFloat(document.getElementById('selling').value); if (cost > 0 && selling > 0) { const profit = selling - cost; const margin = (profit / selling) * 100; document.getElementById('grossProfit').innerText = "R" + profit.toFixed(2); document.getElementById('marginPercent').innerText = margin.toFixed(2) + "%"; document.getElementById('resultsArea').style.display = "block"; } else { alert("Please enter valid numbers"); } } </script>

About

Index.html2

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors