Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would do this with the hover event and changing the class. I am assuming some of your html structure here. I could answer a bit better if I could see it.</p> <pre><code>$('.gallery-single a').hover( function() { if(!$(this).hasClass('slid')) { $(this).find('.gallery-single-title').slideUp(1000); $(this).find('.black').css({ opacity: 0 }); $(this).addClass('slid'); } }, function() { $(this).find('.gallery-single-title').slideDown(1000); $(this).find('.black').css({ opacity: 1 }); $(this).removeClass('slid'); } ); </code></pre> <h2>Update</h2> <p>Here is the updated code to make it behave the way that you want.</p> <p><a href="http://jsfiddle.net/YJaM5/7/" rel="nofollow">http://jsfiddle.net/YJaM5/7/</a></p> <p>There is only one change to the javascript above:</p> <pre><code>$(this).find('.black').animate({ opacity: .5 }); </code></pre> <p>I also recommend setting the event to <code>$('.gallery-single')</code> just in case you ever want to have this effect without the link, but it isn't neccessary.</p> <p>All the other changes are to the css</p> <pre><code>.gallery-single { display:inline-block; margin: 12px; background:#333; width: 300px; height:200px; position:relative; } .gallery-single img { border:none; } .black { background-color:#000000; width:300px; height:200px; position:absolute; top: 0; left: 0; opacity: 0.5; } .gallery-single-title { font-family: 'ContinuumLightRegular', Helvetica, Arial, sans-serif; font-weight:bold; font-size: 18px; padding: 5px 5px 0 5px; width:290px; height:60px; bottom: 0; left:0; overflow:hidden; color: white; background:#00b9e1; position:absolute; display:none; } </code></pre> <p>Let me explain a bit. <code>position:relative;</code> is necessary on <code>.gallery-single</code> to keep it all in a neat package. It allows us to set the bottom property to the title element.</p> <p>I added <code>opacity: 0.5;</code> to the <code>.black</code> element so we didn't have to use js.</p> <p>For <code>.gallery-single-title</code> I removed the <code>margin-top</code> and set </p> <pre><code>bottom: 0; left:0; </code></pre> <p>This will slide the title element up and down regardless of the slideUp or slideDown but it doesn't matter because we are achieving the correct effect.</p> <p>This should work for you now.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload