0

here is an example: http://metalabdesign.com/company/

I want it to be simple and NOT use any JS please. I keep getting stuck on knowing the css positioning needed for this. I know i will need to use a hover as well.

user3224106
  • 11
  • 1
  • 2
  • If you can paste in the code you already have, perhaps someone can suggest some tweaks or fixes. – JakeParis Feb 20 '14 at 03:33
  • Something similar to your question has been answered here: http://stackoverflow.com/questions/14263594/how-to-show-text-on-image-when-hovering – HackerKarma Feb 20 '14 at 03:38

2 Answers2

0

You can set a wrapper div that goes around the image and the caption. Have the caption hidden by default.

Then use a selector to target the caption, but only when the wrapper being hovered.

Edit

You want to have the caption positioned absolutely and relative to the wrapper. This will make it appear on top of the image.

http://jsfiddle.net/9eRXG/

HTML

<figure>
    <img src="http://lorempixel.com/400/200/nature/">
    <figcaption>Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</figcaption>
</figure>

CSS

figcaption {
    display: none;
    position: absolute;
}

figure:hover figcaption {
    display: block;
}

figure {
    position: relative;
}
thgaskell
  • 12,772
  • 5
  • 32
  • 38
0

Check this out .

Fiddle

HTML

<ul class="dogs">
    <li class="dog">
        <img class="dog-photo" src="http://placehold.it/200x300" />
        <div class="dog-info">
             <h3 class="info-name">Dog 1</h3>
             <span class="info-title">Founder / CEO</span>
        </div>
    </li>
    <li class="dog">
        <img class="dog-photo" src="http://placehold.it/200x300" />
        <div class="dog-info">
             <h3 class="info-name">Dog 2</h3>
             <span class="info-title">Founder / CEO</span>
        </div>
    </li>
</ul>

CSS

.dogs{
    margin:0;
    list-style-type:none;
}
.dog {
    width:200px;
    height:300px;
    position:relative;
    float:left;
    margin-right:20px;
}
.dog:hover .dog-info{
    opacity:1;
}
.dog-info {
    position:absolute;
    width:100%;
    height:100%;
    background:rgba(255,255,255,0.8);
    top:0;
    left:0;
    opacity:0;
}
.info-name,.info-title{
    position:relative;
    left:50%;
    width:100px;
    margin-left:-50px;
    text-align:center;
    display:block;
}
.info-name{top:35%;}
.info-title{top:35%;}
Community
  • 1
  • 1
Adrian Enriquez
  • 8,175
  • 7
  • 45
  • 64