အရောင် ရွေးရန် (type="color")
HTML Living Standard
Browser ရဲ့ color picker ကို ဖွင့်ပါတယ်။ Hex digit ခြောက်လုံးပါတဲ့ အရောင်တန်ဖိုးကို browser အများစုမှာ သုံးနိုင်ပါတယ်။
Code စမ်းလို့ရတဲ့ သင်ခန်းစာ ဖွင့်ရန်
ဒီစာမျက်နှာမှာ
Attribute နဲ့ အလုပ်လုပ်ပုံ
| တန်ဖိုး သို့မဟုတ် ရေးပုံ | အလုပ်လုပ်ပုံ |
|---|---|
value="#008080" | စဖွင့်ချိန် အရောင် သတ်မှတ်ပါတယ်။ |
alpha / colorspace | Browser ပံ့ပိုးရင် alpha ဒါမှမဟုတ် ပိုကျယ်တဲ့ color space ရွေးနိုင်ပါတယ်။ |
နမူနာကို စမ်းကြည့်ပါ
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Color picker</title>
<style>
form { display: grid; gap: 12px; justify-items: start; } output { display: block; margin-top: 10px; }
</style>
</head>
<body>
<form id="demo">
<label>Accent color <input type="color" value="#008080" oninput="swatch.value = this.value"></label>
<output id="swatch">#008080</output>
<button type="submit">Check</button>
</form>
<output id="response"></output>
<script>
const form = document.querySelector('#demo');
form.addEventListener('click', event => {
const submitter = event.target.closest('[type="submit"], [type="image"]');
if (!submitter) return;
event.preventDefault();
if (!form.noValidate && !submitter.formNoValidate && !form.reportValidity()) return;
const values = new FormData(form, submitter);
document.querySelector('#response').textContent =
'Passed validation. Fields received: ' + [...values.keys()].join(', ');
});
</script>
</body>
</html>
စမ်းကြည့်ရင် ဘာဖြစ်မလဲ အရောင်အသစ် ရွေးပြီး တန်ဖိုး ဘယ်လိုပြောင်းလဲ ကြည့်ပါ။