สไตล์word การเว้นวรรค คุณสมบัติ
ตัวอย่าง
กำหนดช่องว่างระหว่างคำใน <p> องค์ประกอบ 50 พิกเซล:
document.getElementById("myP").style.wordSpacing = "50px";
ความหมายและการใช้งาน
คุณสมบัติ wordSpacing ตั้งค่าหรือส่งคืนระยะห่างระหว่างคำในข้อความ
เคล็ดลับ:เมื่อต้องการตั้งค่าหรือส่งคืนระยะห่างระหว่างอักขระในข้อความ ให้ใช้คุณสมบัติletterSpacing
รองรับเบราว์เซอร์
Property | |||||
---|---|---|---|---|---|
WordSpacing | Yes | Yes | Yes | Yes | Yes |
ไวยากรณ์
ส่งคืนคุณสมบัติ wordSpacing:
object.style.wordSpacing
ตั้งค่าคุณสมบัติ wordSpacing:
object.style.wordSpacing = "normal|length|initial|inherit"
มูลค่าทรัพย์สิน
Value | Description |
---|---|
normal | Defines normal spacing between words. This is default |
length | Specifies the space between words in length units. Negative values are allowed |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
รายละเอียดทางเทคนิค
ค่าเริ่มต้น: | ปกติ |
---|---|
คืนมูลค่า: | สตริง แทนช่องว่างระหว่างคำในข้อความ |
เวอร์ชัน CSS | CSS1 |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
ใช้ค่าลบ:
document.getElementById("myP").style.wordSpacing = -3px";
ตัวอย่าง
กลับระยะห่างระหว่างคำของ <p> องค์ประกอบ:
alert(document.getElementById("myP").style.wordSpacing);
ตัวอย่าง
ความแตกต่างระหว่างคุณสมบัติ letterSpacing และคุณสมบัติ wordSpacing:
function changeLetters() {
document.getElementById("myP1").style.letterSpacing = "15px";
}
function changeWords() {
document.getElementById("myP2").style.wordSpacing = "15px";
}
หน้าที่เกี่ยวข้อง
กวดวิชา CSS: CSS Text
การอ้างอิง CSS: คุณสมบัติการเว้นวรรคคำ
❮ สไตล์วัตถุ