Convert centiliter to milliliter
cL
ml
.calculator-container { background-color: #f4f4f8; /* Very light grey background */ padding: 20px; border-radius: 12px; width: 100%; max-width: 400px; margin: 0 auto; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); /* Softer shadow */ } .calculator-container h2, .calculator-container h3 { text-align: center; color: #2C3E50; /* Dark blue-grey for headings */ margin-bottom: 20px; } .calculator-container .input-container { margin-bottom: 18px; } .calculator-container .input-group { display: flex; justify-content: space-between; flex-wrap: nowrap !important; align-items: center; border: 2px solid #B2BABB; /* Soft grey-blue border for input group */ border-radius: 6px; padding-right: 5px; } .calculator-container .output-group { background: #ECEFF1 !important; border: #ECEFF1 !important; } .output-group input, select { background: transparent !important; } .calculator-container .input-group:focus-within { border-color: #2980B9; /* Deep blue on focus */ } .calculator-container input { flex-grow: 1; padding: 10px; border: none; font-size: 16px; border-radius: 6px; min-width: 50%; background-color: #FFFFFF; /* White input background */ color: #2C3E50; /* Dark blue-grey text */ } .calculator-container .unit-select { width: auto; padding: 10px; font-size: 14px; background-color: #ECF0F1; /* Light grey background for dropdown */ border: none; border-radius: 6px; padding-right: 5px; color: #2C3E50; /* Dark blue-grey text */ } .calculator-container input:focus-visible, .calculator-container .unit-select:focus-visible { outline: none; } .calculator-container input[type=”number”]::-webkit-inner-spin-button, .calculator-container input[type=”number”]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; } .calculator-container label { color: #34495E; /* Darker blue-grey label */ font-size: 12px; font-weight: 600; } .calculator-container .result-display { font-size: 14px; color: #7F8C8D; /* Medium grey text for result display */ font-weight: 600; } .calculator-container .cost-section { margin-top: 20px; border-top: 1px solid #D5D8DC; padding-top: 10px; } /* Responsive Styles */ @media (max-width: 768px) { .calculator-container { padding: 15px; max-width: 95%; } .calculator-container input, .calculator-container .unit-select { font-size: 14px; padding: 8px; } .calculator-container .result-display { font-size: 14px; } } @media (max-width: 480px) { .calculator-container { padding: 10px; } .calculator-container input, .calculator-container .unit-select { font-size: 12px; padding: 6px; } .calculator-container .result-display { font-size: 12px; } } .button-container { display: flex; /* Use flexbox to arrange buttons in a row */ justify-content: space-between; /* Space evenly between buttons */ margin-top: 20px; /* Space above the buttons */ } .button-container button { background-color: #473350; /* Purple background for buttons */ color: white; /* Text color */ border: none; /* Remove default border */ border-radius: 6px; /* Rounded corners */ padding: 10px 15px; /* Padding for better touch target */ font-size: 16px; /* Font size */ cursor: pointer; /* Pointer cursor on hover */ transition: background-color 0.3s, transform 0.2s; /* Smooth transition for hover effects */ display: flex; /* Flexbox for aligning icon and text */ align-items: center; /* Center align icon and text vertically */ gap: 8px; /* Space between icon and text */ } .button-container button:hover { background-color: #583864; /* Darker purple on hover */ transform: translateY(-2px); /* Slight lift effect on hover */ } .button-container button:active { transform: translateY(0); /* Reset on active */ } .button-container button svg { fill: white; /* Icon color */ } /* Print button specific styles */ #print-button { background-color: #91615c; /* Dark red background for print button */ } #print-button:hover { background-color: #7a4642; /* Darker maroon on hover */ } document.addEventListener(“DOMContentLoaded”, function () { // Add event listeners for both inputs const centiliterInput = document.getElementById(“centiliter”); const milliliterInput = document.getElementById(“milliliter”); const formulaLabel = document.getElementById(“formulaLabel”); const conversionChart = document.getElementById(“conversionChart”); // Event listener for Centiliter input centiliterInput.addEventListener(“input”, function () { const centiliterValue = parseFloat(this.value); if (!isNaN(centiliterValue)) { // Calculate milliliter equivalent const milliliterValue = centiliterValue * 10; milliliterInput.value = milliliterValue.toFixed(2); // Update the formula explanation dynamically updateFormulaExplanation(“cL to mL”, centiliterValue, milliliterValue); // Update conversion chart dynamically generateConversionChart(“cL to mL”, centiliterValue); } else { clearInputsAndChart(); } }); // Event listener for Milliliter input milliliterInput.addEventListener(“input”, function () { const milliliterValue = parseFloat(this.value); if (!isNaN(milliliterValue)) { // Calculate centiliter equivalent const centiliterValue = milliliterValue / 10; centiliterInput.value = centiliterValue.toFixed(2); // Update the formula explanation dynamically updateFormulaExplanation(“mL to cL”, milliliterValue, centiliterValue); // Update conversion chart dynamically generateConversionChart(“mL to cL”, centiliterValue); } else { clearInputsAndChart(); } }); // Function to update formula explanation dynamically function updateFormulaExplanation(direction, inputValue, convertedValue) { if (direction === “cL to mL”) { formulaLabel.textContent = `Conversion Formula: ${inputValue} cL × 10 = ${convertedValue.toFixed(2)} mL`; } else if (direction === “mL to cL”) { formulaLabel.textContent = `Conversion Formula: ${inputValue} mL ÷ 10 = ${convertedValue.toFixed(2)} cL`; } } // Function to generate conversion chart dynamically function generateConversionChart(direction, startValue) { let chartHTML = “
Conversion Chart
Centiliter (cL) | Milliliter (mL) |
---|---|
${cL} | ${mL} |
${cL} | ${mL} |