Zum Inhalt springen

CSS margin-right-Eigenschaft

Die Eigenschaft margin-right definiert, wie groß der rechte Außenabstand des Elements festgelegt wird.

INFO

Negative Werte sind erlaubt.

Anfangswert0
Gilt fürAlle Elemente. Gilt auch für ::first-letter.
VererbtNein.
AnimierbarJa. Der rechte Außenabstand des Elements ist animierbar.
VersionCSS2
DOM-Syntaxobject.style.marginRight = "50px";

Syntax

Syntax der CSS margin-right-Eigenschaft

css
margin-right: length | auto | initial | inherit;

Beispiel für die margin-right-Eigenschaft:

Beispiel für die CSS margin-right-Eigenschaft mit px-Wert

html
<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .right {
        margin-right: 400px;
      }
    </style>
  </head>
  <body>
    <h2>Margin-right property example</h2>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
    <p class="right">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
  </body>
</html>

Ergebnis

CSS margin-right-Eigenschaft

Beispiel für die margin-right-Eigenschaft in "%":

Beispiel für die CSS margin-right-Eigenschaft mit %-Wert

html
<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .right {
        margin-right: 50%;
      }
    </style>
  </head>
  <body>
    <h2>Margin-right property example</h2>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
    <p class="right">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
  </body>
</html>

Beispiel für die margin-right-Eigenschaft mit dem Wert "auto":

Beispiel für die margin-right-Eigenschaft mit dem Wert "auto":

html
<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .right {
        margin-right: auto;
      }
    </style>
  </head>
  <body>
    <h2>Margin-right property example</h2>
    <p>
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry.
    </p>
    <p class="right">
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry.
    </p>
  </body>
</html>

Werte

WertBeschreibungAusführen
autoLegt den rechten Außenabstand fest. Dies ist der Standardwert dieser Eigenschaft.Ausführen »
lengthDefiniert einen rechten Außenabstand in px, pt, cm usw. Der Standardwert ist 0.Ausführen »
%Legt den rechten Außenabstand in % des Elternelements fest.Ausführen »
initialLegt fest, dass die Eigenschaft ihren Standardwert verwendet.Ausführen »
inheritErbt die Eigenschaft von ihrem Elternelement.

Praxis

Was macht die CSS-Eigenschaft 'margin-right'?

Finden Sie das nützlich?

Dual-run-Vorschau — vergleichen Sie mit den Symfony-Routen live.