tags:

views:

36

answers:

1

The title pretty much says it all. There are tons of scripts out there that do so, but most of them are so bloated and end up messing up script, and just use info from alt tags. My script goes as follows:

<ul>
     <li style="display:block">
           <img src="images/portfolio/talktostrangers/1.jpg" />
                <div class="caption">
                <span class="projecttitle">Talk to Strangers</span>A social awareness campaign that proposes people talk to strangers on trains, subways, elevators, & the like.
                </div>
     </li>
</ul>

The preview can be viewed here to get an idea of where it will go: http://www.studioimbrue.com/beta

A: 

If I understand correctly, you just want the caption to show when hovering over an image. The best way to do that is with javascript. I recommend using a js Framework, like jQuery, which makes it really easy. You can just include the jQuery source code and put this in a script tag or an external file within the head of your document.

$(document).ready(function(){
    $('li img').hover(function(){
       $(this).siblings('div.caption').fadeIn('slow');
    }, function(){
       $(this).siblings('div.caption').fadeOut('slow');
    });
});

Then it's all about css styling, opacity, background-color, text-color. Up to you.

Regarding the 100% width in the title of your question, because it's in a DIV tag, it should automatically fill 100% of it's parent, the LI.

munch
Thank you for the quick response!My site is heavily relying on javascript and CSS, you should check the link I posted above: http://www.studioimbrue.com/betaI have added the script you gave (almost perfect!) but it's not hovering over the image, and when the page loads it's automatically showing. I know these are simple things but my javascript coding abilities are definitely lacking... again, thanks.
steve
The thumbs are also another issue, I'm not sure if I have to post that as well. I found the javascript solution on here and everything works, except when a different thumb is clicked, it doesn't clear the .selected class from the other thumbs. If you can help with that, too, that'd be awesome (or I'll post another query on the site.)
steve
Oh, I fixed the positioning. Now it's just a matter of making them hidden until moused over!
steve
I added $('div.caption').hide(); right after ready(function(){ and that seemed to do the trick! If there's a better way of doing it, let me know. Thanks for your help again, it's working perfectly!
steve
That's one option. The other is putting that into your css `.caption{ display:none; }`. Either way will do the trick! Glad it's working
munch