Ich mache eine Einrichtung, wo zwei Bilder und ein Text-Container nebeneinander sind mit Float links, aber ich brauche auch eine Overlay-Div mit etwas Text, wenn der Benutzer über schwebt, aber Dies unterbricht die Anzeige.Absolute Position für Kind, wenn Eltern Float verwenden
Hier ist mein HTML-Code:
<div class="container">
<div class="parent-container">
<div class="child-container">
<img src="http://blog.hdwallsource.com/wp-content/uploads/2016/02/solid-color-wallpaper-21953-22506-hd-wallpapers.jpg" alt="" />
<div class="overlay">
<p>Some text</p>
</div>
</div>
<div class="child-container">
<img src="http://www.pixelstalk.net/wp-content/uploads/2016/06/Solid-Color-HD-Wallpapers-For-Desktop-768x432.jpg" alt="" />
</div>
<div class="child-container-text">
<p>hhohdoioadoasabs</p>
</div>
</div>
</div>
Und hier ist mein CSS:
.parent-container {
position: relative;
width: 100%;
}
.child-container {
float: left;
position: relative;
width: 30%;
}
.child-container img {
position: absolute;
height: 100px;
width: 100%;
}
.child-container-text {
background-color: #000;
float: left;
height: 100px;
position: absolute;
width: 40%;
}
.overlay {
background-color: #FFF;
opacity: 0.3;
position: absolute;
z-index: 999;
}
Und hier ist ein CodePen mit ihm: https://codepen.io/leofontes/pen/ORPJWd?editors=1100
Jede Idee, warum sie gestapelt werden immer ? Ich hatte den gleichen Trick absoluter Positionierung für Overlays vor und es funktionierte, warum bricht der Schwimmer es?
Danke
Ich habe auch Probleme, das Problem zu finden. Nachdem ich mit dem Code herumgespielt hatte, wurde mir klar, dass er genau das tut, was man von diesem Code erwartet. – NoobishPro