Color Converter

Color Converter

Color Converter

body { font-family: 'Arial', sans-serif; background-color: #f4f4f4; margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; height: 100vh; } .converter-container { background-color: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); text-align: center; } h1 { color: #333; } .input-section { margin-bottom: 20px; } label { font-weight: bold; display: block; margin-bottom: 5px; } input { padding: 8px; font-size: 16px; width: 60%; } button { padding: 8px; font-size: 16px; cursor: pointer; } .output-section { display: flex; flex-direction: column; align-items: center; } .color-box { width: 100px; height: 100px; margin-top: 10px; } #convertedValues { margin-top: 10px; } function convertColor() { const colorInput = document.getElementById('colorInput').value.trim(); const convertedColor = document.getElementById('convertedColor'); const convertedValues = document.getElementById('convertedValues'); try { const color = tinycolor(colorInput); if (color.isValid()) { convertedColor.style.backgroundColor = color.toHexString(); convertedValues.innerHTML = `

HEX: ${color.toHexString()}

RGB: ${color.toRgbString()}

HSL: ${color.toHslString()}

`; } else { alert('Invalid color input. Please enter a valid HEX, RGB, or HSL color.'); } } catch (error) { alert('An error occurred while converting the color. Please try again.'); } }

No comments:

Post a Comment

Screen Recorder Screen Recorder Tool Start Recording Stop Recording ...