So this is killing me.
I have looked at lots of forums but I can't seem to get any solutions to work.
Basically I have a grid of floated elements, each with a thumbnail image that on hover, has an overlay and text description of what that gallery contains (it's a typical looking folio site).
Usually I just have a fixed layout with an overlay box the same size as each image and a text container the same width which turns on and off on hover and thats fine. BUT - this is my first responsive version of the site and I have no idea how to make the size of the overlay and text match the dimensions of their parent.
I tried wrapping them all in a div but the child elements seem to ignore the parents dimensions anyway - presumably because they are floated.
I am using a fancybox gallery, the thumbnail image in question is marked with a comment but otherwise that works perfectly.
Is there a way to tell one div to match the width of another responsive img? Any help would be much appreciated.
Here is my html
<div class="flex_one">
<div class="blackbox"><!--black low opacity box - appears on hover--></div>
<div class="textcontainer"><h2>ART</h2></div>
<a class="fancybox-thumb" rel="gallery2" href="image1.jpg"><!--gallery image 1-->
<img class="icon-image" src="thumb.jpg" alt="main icon" /><!--This is the thumbnail image on page-->
</a>
<a class="fancybox-thumb" rel="gallery2" href="image2.jpg"><!--gallery image 2-->
</a>
This is my CSS
.flex_one {
width:28%;
height:auto;
float:left;
background-color:#000;
overflow:hidden;
margin-left:4%;
margin-top:4%;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.icon-image {
width:100%;
height:auto;
}
.blackbox {
height:???;
width:??;
overflow:auto;
opacity:0;
background-color:#000;
position: absolute;
pointer-events:none;
}
.textcontainer {
width:??;
margin-top:0px;
height: 20px;
background-color:rgba(0,0,0,0);
pointer-events:none;
position:absolute;
background-color:transparent;
}
.textcontainer h2{
text-decoration: none;
font-size: 13px;
font-family: 'Raleway', sans-serif; text-transform: uppercase;
color:#FFF;
z-index:80000;
opacity:0;
transform:scale(0);
}
.flex_one:hover > .textcontainer h2 {
transform:scale(1);
opacity:1;
}
.flex_one:hover > .blackbox {
opacity:.7;
}