Showing post title as overlay on featured image on hover
-
Hi everyone,
I am building a static homepage which features a number of books. The front page only shows covers and I want each image to show the title over the image when the mouse is hovered. At present I have it so that the opacity changes, which I want, but I can’t get it to pull and display the title.
I really want to be able to do this with PHP as the home page content will change (it will display books tagged with ‘featured’). My assumption is that it would be possible to do this by calling ‘<? php get_title(); ?>’ etc while hovered but no luck.
Can anyone put me on the right track with this? The two bits of code I have in place at the moment relating to this are below.
home.php:
<span class="new-wrapper"> <a href="<?php the_permalink() ?>"><?php echo get_the_post_thumbnail( $post_id, $size=0, $attr ); ?></a> </span>
CSS
.new-wrapper {float: left; width: 95px; height: 150px; margin: 0px 10px 5px 0px;} .new-wrapper:hover {opacity: 0.25; filter: alpha(opacity=100); -webkit-transition: opacity .15s linear;}
- The topic ‘Showing post title as overlay on featured image on hover’ is closed to new replies.