--- title: margin-top slug: Web/CSS/margin-top tags: - CSS - CSS Property - Reference translation_of: Web/CSS/margin-top ---
La propietat CSS margin-top estableix l'àrea de marge en la part superior d'un element . Un valor positiu el situarà més enllà del normal dels seus veïns, mentre que un valor negatiu el situarà més a prop.
/* <length> values */ margin-top: 10px; /* An absolute length */ margin-top: 1em; /* relative to the text size */ margin-top: 5%; /* relative to the nearest block container's width */ /* Keyword values */ margin-top: auto; /* Global values */ margin-top: inherit; margin-top: initial; margin-top: unset;
{{cssinfo}}
La propietat margin-top és especificada amb la paraula clau auto, o un <length>, o un <percentage>. El seu valor pot ser positiu, zero o negatiu.
auto{{csssyntax}}
.content { margin-top: 5%; }
.sidebox { margin-top: 10px; }
.logo { margin-top: -5px; }
#footer { margin-top: 1em; }
| Especificació | Estat | Comentsri |
|---|---|---|
| {{SpecName('CSS3 Box', '#the-margin', 'margin-top')}} | {{Spec2('CSS3 Box')}} | No hi ha cap canvi significatiu |
| {{SpecName('CSS3 Transitions', '#animatable-css', 'margin-top')}} | {{Spec2('CSS3 Transitions')}} | Defineix margin-top com animable. |
| {{SpecName('CSS2.1', 'box.html#margin-properties', 'margin-top')}} | {{Spec2('CSS2.1')}} | Elimina el seu efecte en els elements en línia |
| {{SpecName('CSS1', '#margin-top', 'margin-top')}} | {{Spec2('CSS1')}} | Definició inicial. |
{{CompatibilityTable()}}
| Descripció | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|---|
| Suport bàsic | 1.0 | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("1")}} | 3.0 | 3.5 | 1.0 (85) |
|
valor |
1.0 | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("1")}} | 6.0 (strict mode) | 3.5 | 1.0 (85) |
| Descripció | Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Suport bàsic | 1.0 | {{CompatVersionUnknown}} | {{CompatGeckoMobile("1")}} | 6.0 | 6.0 | 1.0 |