Style marginBottom Property
Przykład
Ustaw dolny margines elementu <div>:
document.getElementById("myDiv").style.marginBottom = "50px";
Definicja i użycie
Właściwość marginBottom ustawia lub zwraca dolny margines elementu.
Zarówno właściwość margin, jak i właściwość padding wstawiają spację wokół elementu. Różnica polega jednak na tym, że margin wstawia spację wokół obramowania, a padding wstawia spację w obramowaniu elementu.
Obsługa przeglądarki
Property | |||||
---|---|---|---|---|---|
marginBottom | Yes | Yes | Yes | Yes | Yes |
Składnia
Zwróć właściwość marginBottom:
object.style.marginBottom
Ustaw właściwość marginBottom:
object.style.marginBottom = "%|length|auto|initial|inherit"
Wartości nieruchomości
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 |
Szczegóły techniczne
Domyślna wartość: | 0 |
---|---|
Wartość zwrotu: | String, reprezentujący dolny margines elementu |
Wersja CSS | CSS1 |
Więcej przykładów
Przykład
Zmień dolny margines elementu <div> z powrotem na „normalny”:
document.getElementById("myDiv").style.marginBottom = "0px";
Przykład
Zwróć dolny margines elementu <div>:
alert(document.getElementById("myDiv").style.marginBottom);
Przykład
Różnica między marginBottom a paddingBottom:
function changeMargin() {
document.getElementById("myDiv").style.marginBottom = "100px";
}
function changePadding() {
document.getElementById("myDiv2").style.paddingBottom = "100px";
}
Powiązane strony
Samouczek CSS: margines CSS
Odniesienie CSS: właściwość margin-bottom
Dokumentacja HTML DOM: właściwość margin
❮ Obiekt stylu