Overlay on image problem

Need help with image overlay. I made a jsfiddle http://jsfiddle.net/7upzLdee/1/

<div class="rss-output" style="float:">
<div class="body"> 
<div class="overlay-feed"></div>
<div class="imagefix" style="float:none;">
<a target="_blank" href="#">
<img  src="http://www.gettyimages.co.uk/CMS/StaticContent/1391099215267_hero2.jpg" alt="" height="337" width="600"/></a>
</div>
</div>
</div>

div.rss-output {
float: left;
width: 33.333%;
position: relative;
padding: 15px !important;
overflow: hidden;
}

.rss-output .body {
width: 100%;
}

.rss-output .overlay-feed {
background: #000 none repeat scroll 0% 0%;
z-index: 1;
position: absolute;
width: 100%;
height: 200px;
opacity: 0.5;
}

div.imagefix {
height: 200px;
line-height: 250px;
overflow: hidden;
text-align: center;
width: 100%;
}

div.imagefix img {
margin: -50%;
}

      

I cannot understand why the inscription follows the image on the right side. I have tried many things but no luck.

All help is appreciated.

Thank you in advance

+3


source to share


3 answers


add position: relative

for.rss-output .body



div.rss-output {
    float: left;
    width: 33.333%;
    position: relative;
    padding: 15px !important;
    overflow: hidden;
}

.rss-output .body {
    width: 100%;
    position: relative;
}

.rss-output .overlay-feed {
    background: #000 none repeat scroll 0% 0%;
    z-index: 1;
    position: absolute;
    width: 100%;
    height: 200px;
    opacity: 0.5;
}

div.imagefix {
    height: 200px;
    line-height: 250px;
    overflow: hidden;
    text-align: center;
    width: 100%;
}

div.imagefix img {
    margin: -50%;
}
      

<div class="rss-output" style="float:">
<div class="body"> 
    <div class="overlay-feed"></div>
    <div class="imagefix" style="float:none;">
        <a target="_blank" href="#">
            <img src="http://www.gettyimages.co.uk/CMS/StaticContent/1391099215267_hero2.jpg" alt="" height="337" width="600"/></a>
    </div>
    </div>
</div>
      

Run codeHide result


+2


source


added position:relative;

to the body because when you use position:absolute;

for some element it will ignore static parents and hence its width



div.rss-output {
    float: left;
    width: 33.333%;
    position: relative;
    padding: 15px !important;
    overflow: hidden;
}

.rss-output .body {
    width: 100%;
    position:relative;
}

.rss-output .overlay-feed {
    background: #000 none repeat scroll 0% 0%;
    z-index: 1;
    position: absolute;
    width: 100%;
    height: 200px;
    opacity: 0.5;
}

div.imagefix {
    height: 200px;
    line-height: 250px;
    overflow: hidden;
    text-align: center;
    width: 100%;
}

div.imagefix img {
    margin: -50%;
}
      

<div class="rss-output" style="float:">
<div class="body"> 
    <div class="overlay-feed"></div>
    <div class="imagefix" style="float:none;">
        <a target="_blank" href="#">
            <img src="http://www.gettyimages.co.uk/CMS/StaticContent/1391099215267_hero2.jpg" alt="" height="337" width="600"/></a>
    </div>
    </div>
</div>
      

Run codeHide result


0


source


The problem is the width of the overlay.

.rss-output .overlay-feed {
    background: #000 none repeat scroll 0% 0%;
    z-index: 1;
    position: absolute;
    width: 89%;
    height: 200px;
    opacity: 0.5;
}

      

do overlay width 89%. fiddle

0


source







All Articles