CSS margin-right Właściwość
Przykład
Ustaw prawy margines dla elementu <p> na 150 pikseli:
p.ex1 {
margin-right: 150px;
}
Więcej przykładów „Wypróbuj sam” poniżej.
Definicja i użycie
Właściwość margin-right
ustawia prawy margines elementu.
Uwaga: Dopuszczalne są wartości ujemne.
Domyślna wartość: | 0 |
---|---|
Dziedziczny: | nie |
Animowalny: | tak, zobacz poszczególne właściwości . Przeczytaj o animacji |
Wersja: | CSS1 |
Składnia JavaScript: | obiekt .style.marginRight="100px" |
Obsługa przeglądarki
Liczby w tabeli określają pierwszą wersję przeglądarki, która w pełni obsługuje tę właściwość.
Property | |||||
---|---|---|---|---|---|
margin-right | 1.0 | 6.0 | 1.0 | 1.0 | 3.5 |
Składnia CSS
margin-right: length|auto|initial|inherit;
Wartości nieruchomości
Value | Description | Play it |
---|---|---|
length | Specifies a fixed right margin in px, pt, cm, etc. Default value is 0px. Read about length units | |
% | Specifies a right margin in percent of the width of the containing element | |
auto | The browser calculates a right margin | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
Więcej przykładów
Przykład
Ustaw prawy margines elementu <p> na 50% szerokości kontenera:
p.ex1 {
margin-right: 50%;
}
Przykład
Ustaw prawy margines dla elementu <p> na 15 em:
p.ex1 {
margin-right: 15em;
}
Powiązane strony
Samouczek CSS: margines CSS
Dokumentacja HTML DOM: właściwość marginRight