Hallo Ich versuche, das Sie Relative Positionierung mit Höhe basierend auf dem Inhalt Probleme
So kann in diesem Fall zu erreichen sehen, haben wir 3 divs. Die oberste hat eine Breite von 100% und eine Höhe: auto. Wird natürlich auch relativ positioniert sein.
Zweite gleich, aber in diesem Fall werde ich einen Dummy-Text hinzufügen, der die Höhe des div definieren wird.
Und die dritte wie die erste, das Problem ist, dass sie nicht ausgerichtet sind. Nicht eins vor dem anderen. Könnte mir jemand sagen, was mit meinem Code nicht stimmt? Dank
#block1 {
position:relative;
width:100%;
height:auto;
background-color: blue;
}
#img1 {
width:100px;
height:100px;
position:absolute;
left:50%;
transform:translate(-50%);
-webkit-transform:translate(-50%);
}
#block2 {
position:relative;
width:100%;
height:auto;
background-color: orange;
}
.dummytext {
font-family: 'Ralleway, sans-serif';
font-size: 20px;
text-align: justify;
margin:10px;
}
#block3 {
position:relative;
width:100%;
height:auto;
background-color: brown;
}
#img2 {
width:100px;
height:90px;
position:absolute;
left:50%;
transform:translate(-50%);
-webkit-transform:translate(-50%);
}
<div id="block1">
<img src="images/img1.png" id="img1"/>
</div>
<div id="block2">
<h3 class="dummytext">Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, Text Example, </h3>
</div>
<div id="block3">
<img id="img2" src="images/img2.png"/>
</div>
Könnte jemand mir helfen, zu verstehen?
Da Ihr img ist 'Position: absolute'. Warum? –