【发布时间】:2015-04-20 22:35:01
【问题描述】:
我正在尝试对我的 WP 主题中的图像应用悬停效果。它是由帖子上的特色图像创建的图像网格。
网格在 content.php 中控制
<?php
/**
* controls main grid images
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class('col-md-4 col-sm-4 pbox '); ?>>
<div class = "box-ovrly">
<h2 class="box-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div class="box-meta"><?php the_category(', '); ?></div>
</div>
<?php
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb,'full' ); //get full URL to image (use "large" or "medium" if the images too big)
$image = aq_resize( $img_url, 750, 560, true ); //resize & crop the image
?>
<?php if($image) : ?>
<a href="<?php the_permalink(); ?>"> <img class="img-responsive hover-decal" src="<?php echo $image ?>"/></a>
<?php endif; ?>
</article><!-- #post-## -->
我想将'box-overly' div 转换为图像顶部的叠加层,但找不到合适的 js 和 css。
我现在拥有的 css ...
.box-ovrly {
z-index: 100;
position: absolute;
top: 0px
left: 0px;
}
它将标题和类别放在图像的顶部。我希望它有一个背景来覆盖悬停时的图像,但在悬停之前根本不显示
我想要做的事情的完美例子(最终不同的背景颜色等。但我不希望图像上的任何文字直到悬停)在这个投资组合中
【问题讨论】:
标签: javascript jquery html css wordpress