สไตล์maxHeightคุณสมบัติ
ตัวอย่าง
กำหนดความสูงสูงสุดของ <div> องค์ประกอบ:
document.getElementById("myDIV").style.maxHeight = "15px";
ความหมายและการใช้งาน
คุณสมบัติ maxHeight ตั้งค่าหรือส่งคืนความสูงสูงสุดขององค์ประกอบ
คุณสมบัติ maxHeight มีผลเฉพาะกับองค์ประกอบระดับบล็อกหรือองค์ประกอบที่มีตำแหน่งที่แน่นอนหรือคงที่
หมายเหตุ:ความสูงขององค์ประกอบไม่สามารถมากกว่าค่าที่ระบุโดยคุณสมบัติ maxHeight
เคล็ดลับ:หากต้องการตั้งค่าหรือคืนค่าความสูงขั้นต่ำขององค์ประกอบ ให้ใช้คุณสมบัติminHeight
รองรับเบราว์เซอร์
Property | |||||
---|---|---|---|---|---|
maxHeight | Yes | Yes | Yes | Yes | Yes |
ไวยากรณ์
ส่งคืนคุณสมบัติ maxHeight:
object.style.maxHeight
ตั้งค่าคุณสมบัติ maxHeight:
object.style.maxHeight = "none|length|%|initial|inherit"
มูลค่าทรัพย์สิน
Value | Description |
---|---|
none | No limit on the height of the element. This is default |
length | Defines the maximum height in length units |
% | Defines the maximum height in % of the parent element |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
รายละเอียดทางเทคนิค
ค่าเริ่มต้น: | ไม่มี |
---|---|
คืนมูลค่า: | สตริงที่แสดงถึงความสูงสูงสุดขององค์ประกอบ |
เวอร์ชัน CSS | CSS2 |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
ส่งคืนความสูงสูงสุดของ <div> องค์ประกอบ:
alert(document.getElementById("myDIV").style.maxHeight);
หน้าที่เกี่ยวข้อง
กวดวิชา CSS: CSS Dimension
การอ้างอิง CSS: คุณสมบัติความสูงสูงสุด
❮ สไตล์วัตถุ