Gaya marginBottom Property
Contoh
Setel margin bawah elemen <div>:
document.getElementById("myDiv").style.marginBottom = "50px";
Definisi dan Penggunaan
Properti marginBottom menetapkan atau mengembalikan margin bawah suatu elemen.
Baik properti margin dan properti padding menyisipkan ruang di sekitar elemen. Namun, perbedaannya adalah margin menyisipkan ruang di sekitar perbatasan, sedangkan padding menyisipkan ruang di dalam batas elemen.
Dukungan Peramban
Property | |||||
---|---|---|---|---|---|
marginBottom | Yes | Yes | Yes | Yes | Yes |
Sintaksis
Kembalikan properti marginBottom:
object.style.marginBottom
Setel properti marginBottom:
object.style.marginBottom = "%|length|auto|initial|inherit"
Nilai properti
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 |
Detail Teknis
Nilai Bawaan: | 0 |
---|---|
Nilai Kembali: | Sebuah String, mewakili margin bawah suatu elemen |
Versi CSS | CSS1 |
Lebih Banyak Contoh
Contoh
Ubah margin bawah elemen <div> kembali ke "normal":
document.getElementById("myDiv").style.marginBottom = "0px";
Contoh
Kembalikan margin bawah elemen <div>:
alert(document.getElementById("myDiv").style.marginBottom);
Contoh
Perbedaan antara marginBottom dan paddingBottom:
function changeMargin() {
document.getElementById("myDiv").style.marginBottom = "100px";
}
function changePadding() {
document.getElementById("myDiv2").style.paddingBottom = "100px";
}
Halaman Terkait
Tutorial CSS: Margin CSS
Referensi CSS: properti margin-bottom
Referensi DOM HTML: properti margin
Objek Gaya