แบบอักษรผ้าใบ HTML คุณสมบัติ
ตัวอย่าง
เขียนข้อความสูง 30px ลงบนผืนผ้าใบโดยใช้แบบอักษร "Arial":
จาวาสคริปต์:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.font = "30px Arial";
ctx.fillText("Hello World", 10, 50);
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนคุณสมบัติอย่างสมบูรณ์
Property | |||||
---|---|---|---|---|---|
font | Yes | 9.0 | Yes | Yes | Yes |
ความหมายและการใช้งาน
คุณสมบัติฟอนต์ตั้งค่าหรือส่งคืนคุณสมบัติฟอนต์ปัจจุบันสำหรับเนื้อหาข้อความบนผ้าใบ
คุณสมบัติฟอนต์ใช้ ไวยากรณ์เดียวกับคุณสมบัติฟอนต์ CSS
ค่าเริ่มต้น: | 10px sans-serif |
---|---|
ไวยากรณ์ JavaScript: | บริบท .font="ตัวเอียงตัวพิมพ์เล็กตัวหนา 12px arial"; |
มูลค่าทรัพย์สิน
Values | Description | Play it |
---|---|---|
font-style | Specifies the font style. Possible values:
|
|
font-variant | Specifies the font variant. Possible values:
|
|
font-weight | Specifies the font weight. Possible values:
|
|
font-size/line-height | Specifies the font size and the line-height, in pixels | |
font-family | Specifies the font family | |
caption | Use the font captioned controls (like buttons, drop-downs, etc.) | |
icon | Use the font used to label icons | |
menu | Use the font used in menus (drop-down menus and menu lists) | |
message-box | Use the font used in dialog boxes | |
small-caption | Use the font used for labeling small controls | |
status-bar | Use the fonts used in window status bar |
❮ การอ้างอิงผ้าใบ HTML