ระยะขอบสไตล์คุณสมบัติ ด้านล่าง
ตัวอย่าง
ตั้งค่าระยะขอบด้านล่างของ <div> องค์ประกอบ:
document.getElementById("myDiv").style.marginBottom = "50px";
ความหมายและการใช้งาน
คุณสมบัติ marginBottom ตั้งค่าหรือคืนค่าระยะขอบด้านล่างขององค์ประกอบ
ทั้งคุณสมบัติระยะขอบและคุณสมบัติช่องว่างภายในจะแทรกพื้นที่รอบองค์ประกอบ อย่างไรก็ตาม ข้อแตกต่างคือระยะขอบจะแทรกช่องว่างรอบ ๆ เส้นขอบ ในขณะที่การเติมจะแทรกช่องว่างภายในเส้นขอบขององค์ประกอบ
รองรับเบราว์เซอร์
Property | |||||
---|---|---|---|---|---|
marginBottom | Yes | Yes | Yes | Yes | Yes |
ไวยากรณ์
ส่งคืนคุณสมบัติ marginBottom:
object.style.marginBottom
ตั้งค่าคุณสมบัติ marginBottom:
object.style.marginBottom = "%|length|auto|initial|inherit"
มูลค่าทรัพย์สิน
Value | Description |
---|---|
% | Defines the bottom margin in % of the width of the parent element |
length | Defines the bottom margin in length units |
auto | The browser sets the bottom margin |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
รายละเอียดทางเทคนิค
ค่าเริ่มต้น: | 0 |
---|---|
คืนมูลค่า: | สตริงที่แสดงถึงระยะขอบด้านล่างขององค์ประกอบ |
เวอร์ชัน CSS | CSS1 |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
เปลี่ยนระยะขอบด้านล่างขององค์ประกอบ <div> กลับเป็น "ปกติ":
document.getElementById("myDiv").style.marginBottom = "0px";
ตัวอย่าง
กลับระยะขอบด้านล่างของ <div> องค์ประกอบ:
alert(document.getElementById("myDiv").style.marginBottom);
ตัวอย่าง
ความแตกต่างระหว่าง marginBottom และ paddingBottom:
function changeMargin() {
document.getElementById("myDiv").style.marginBottom = "100px";
}
function changePadding() {
document.getElementById("myDiv2").style.paddingBottom = "100px";
}
หน้าที่เกี่ยวข้อง
กวดวิชาCSS: มาร์จิ้น CSS
การอ้างอิง CSS: คุณสมบัติ margin-bottom
การอ้างอิง HTML DOM: คุณสมบัติมาร์จิ้น
❮ สไตล์วัตถุ