aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/css/left/index.html
blob: d1e281e4a3e0feca3180f78a8ce7b02a733456d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
---
title: left
slug: Web/CSS/Left
tags:
  - CSS
  - CSS Eigenschaft
  - CSS Positionierung
  - Referenz
translation_of: Web/CSS/left
---
<p>{{CSSRef}}</p>

<h2 id="Übersicht">Übersicht</h2>

<p>Die CSS Eigenschaft <code>left</code> definiert einen Teil der Position von positionierten Elementen.</p>

<p>Bei absolut positionierten Elementen (jene mit {{cssxref("position")}}<code>: absolute</code> oder <code>position: fixed</code>) wird der Abstand zwischen der linken, äußeren Rand des Elements und dem linken Rand des umschließenden Blocks definiert.</p>

<p>{{cssinfo}}</p>

<h2 id="Syntax">Syntax</h2>

<pre class="brush:css">/* &lt;length&gt; Werte */
left: 3px;
left: 2.4em;

/* &lt;percentage&gt; Werte bezogen auf die Breite des beinhaltenden Blocks */
left: 10%;

/* Schlüsselwortwerte */
left: auto;

/* Globale Werte */
left: inherit;
left: initial;
left: unset;
</pre>

<h3 id="Werte">Werte</h3>

<dl>
 <dt><code>&lt;length&gt;</code></dt>
 <dd>Ist eine negative, null oder positive {{cssxref("&lt;length&gt;")}}, die folgendem entspricht:
 <ul>
  <li>für <em>absolute positionierte Elemente</em>, die Distanz zum linken Rand des beinhaltenden Blocks</li>
  <li>für <em>relativ positionierte Elemente</em>, der Versatz, um den das Element von seiner Position im normalen Fluss nach links verschoben ist, falls es nicht positioniert wäre.</li>
 </ul>
 </dd>
 <dt><code>&lt;percentage&gt;</code></dt>
 <dd>Ein {{cssxref("&lt;percentage&gt;")}} Wert der Breite des beinhaltenden Blocks, wie in der <a href="#Übersicht">Übersicht</a> beschrieben.</dd>
 <dt><code>auto</code></dt>
 <dd>Ist ein Schlüsselwort, das folgendem entspricht:
 <ul>
  <li>für absolut positionierte Elemente, die Position des Elements basierend auf der {{cssxref("right")}} Eigenschaft und <code>width: auto</code> wird als Breite basierend auf dem Inhalt behandelt.</li>
  <li>für relativ positionierte Elemente, der linke Versatz des Elements von der Originalposition basierend auf der {{cssxref("right")}} Eigenschaft oder falls <code>right</code> ebenfalls <code>auto</code> ist, wird wird es nicht verschoben.</li>
 </ul>
 </dd>
</dl>

<h2 id="Beispiele">Beispiele</h2>

<h3 id="CSS">CSS</h3>

<pre class="brush: css">#wrap {
  width: 700px;
  margin: 0 auto;
  background: #5C5C5C;
}

pre {
  white-space: pre;
  white-space: pre-wrap;
  white-space: pre-line;
  word-wrap: break-word;
}

#example_1 {
  width: 200px;
  height: 200px;
  position: absolute;
  left: 20px;
  top: 20px;
  background-color: #D8F5FF;
}

#example_2 {
  width: 200px;
  height: 200px;
  position: relative;
  top: 0;
  right: 0;
  background-color: #C1FFDB;

}
#example_3 {
  width: 600px;
  height: 400px;
  position: relative;
  top: 20px;
  left: 20px;
  background-color: #FFD7C2;
}

#example_4 {
  width: 200px;
  height: 200px;
  position: absolute;
  bottom: 10px;
  right: 20px;
  background-color: #FFC7E4;
}</pre>

<h3 id="HTML">HTML</h3>

<pre class="brush: html">&lt;div id="wrap"&gt;
  &lt;div id="example_1"&gt;
    &lt;pre&gt;
      position: absolute;
      left: 20px;
      top: 20px;
    &lt;/pre&gt;
    &lt;p&gt;Das einzige Element, das dieser Div beinhaltet, ist das Hauptfenster. Daher positioniert er sich in Bezug dazu.&lt;/p&gt;
  &lt;/div&gt;

  &lt;div id="example_2"&gt;
    &lt;pre&gt;
      position: relative;
      top: 0;
      right: 0;
    &lt;/pre&gt;
    &lt;p&gt;Relative Position in Bezug auf seine Geschwisterelemente.&lt;/p&gt;
  &lt;/div&gt;

  &lt;div id="example_3"&gt;
    &lt;pre&gt;
      float: right;
      position: relative;
      top: 20px;
      left: 20px;
    &lt;/pre&gt;
    &lt;p&gt;Relativ zu seinem Geschwister-Div darüber, jedoch aus dem Inhaltsfluss entfernt.&lt;/p&gt;

    &lt;div id="example_4"&gt;
      &lt;pre&gt;
        position: absolute;
        top: 10px;
        left: 20px;
      &lt;/pre&gt;
      &lt;p&gt;Absolute Position innerhalb des Elternelements mit relativer Position.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;</pre>

<h3 id="Live_Beispiel">Live Beispiel</h3>

<p>{{EmbedLiveSample('Beispiele', 1200, 650)}}</p>

<h2 id="Spezifikationen">Spezifikationen</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Spezifikation</th>
   <th scope="col">Status</th>
   <th scope="col">Kommentar</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS3 Transitions', '#animatable-css', 'left')}}</td>
   <td>{{Spec2('CSS3 Transitions')}}</td>
   <td>Definiert <code>left</code> als animierbar.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS2.1', 'visuren.html#propdef-left', 'left')}}</td>
   <td>{{Spec2('CSS2.1')}}</td>
   <td>Ursprüngliche Definition</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_Kompatibilität">Browser Kompatibilität</h2>

{{Compat("css.properties.left")}}

<h2 id="Siehe_auch">Siehe auch</h2>

<ul>
 <li>{{cssxref("position")}}, {{cssxref("right")}}, {{cssxref("bottom")}}, {{cssxref("left")}}</li>
</ul>