I have a div that I need to display under another div, but with horizontal alignment as the page resizes. Resizing the page resizes the first div.
I would like to place .div2under .div1and center.
I created a violin to show more clearly what I'm looking for.
HTML
<div class="container">
<img src="http://jamesonstarship.files.wordpress.com/2013/10/beautiful-cat-cats-16096437-1280-800.jpg" />
<div class="floating-container">
<div class="floating" style="left:36%;top:26%;width:6%;height:9.5%;">
<div class="div1">
</div>
<div class="div2">
There is some content here
</div>
</div>
<div class="floating" style="left:55%;top:38%;width:5%;height:8%;">
<div class="div1">
</div>
<div class="div2">
There is some content here
</div>
</div>
</div>
</div>
CSS
.container {
width:100%;
display: inline-block;
position: relative;
}
.container img {
width:100%;
}
.floating {
position:absolute;
}
.div1 {
border: 3px solid #FFF;
border-radius: 3px;
width: 100%;
height: 100%;
}
.div2 {
background: rgba(255,255,255,0.4);
width: 75px;
}
We tried to understand this for a couple of hours, so I would really like some help!
source
share