我有一个 wordpress 博客,在循环中,布局就像左边的文本(标题。日期,摘要),图像向右浮动(向左填充 50%),我想在左边留出 50% 的空间和此(标题。日期,摘要)上的所有元素都可以悬停(悬停左侧区域时,所有文本颜色变为黑色,背景变为#ff7f00;)。
后期CSS
.post-ut {
display:block;
color:#999999;
z-index:2;
float:left;
letter-spacing:1px;
font-size:13px;
position: relative;
width:282px;
}
.post-ut a {
max-width:74px;
min-width:74px;
text-decoration:none;
color: #999999;
display:inline-block;
z-index:1;
}
这是我正在使用的 jQuery 代码的想法,那是行不通的
$('div.post-ut').mouseover(function() {
$('.entry-summary p', $(this).parent())
.css("color","black")
.css("background","#ff7f00");
});
$('div.post-ut').mouseout(function() {
$('.entry-summary p', $(this).parent())
.css("color","white")
.css("background","black");
});
wordress post循环的php代码是
<h1 class="thumb" style="z-index:2; width:252px;">
<a style="padding:15px 15px 5px 15px; width:252px; font-size:30px; font-weight:100; " href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', UT_THEME_NAME ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
</h1>
<br/>
<div class="post-ut" style="margin-top:-43px;">
<?php the_time('d. m. Y, g:i') ?> | <?php lambda_posted_in(); ?>
</div> <!-- post by -->
</header>
<?php
echo '<div class="thumb" style="width:282px; padding-left:282px; margin-top:-114px; margin-bottom:20px; "><div class="post-image"><div class="overflow-hidden imagepost">';
echo '<img class="wp-post-image" style="display:inline-block; width:282px; height:272px;" src="'.$url.'" />';
echo '<a title="'.get_the_title().'" href="'.get_permalink().'"><div class="hover-overlay"><span class="circle-hover"><img src="'.get_template_directory_uri().'/images/circle-hover.png" alt="'.__('link icon',UT_THEME_INITIAL).'" /></span></div></a>';
echo '</div></div></div>';
endif; ?>
<div class="entry-content clearfix">
<div class="entry-summary">
<?php if ( is_archive() || is_search() || get_option_tree('excerpt_blog') == 'yes') :
the_excerpt();
else :
?>
<?php endif; ?>
</div><!-- .entry-summary -->
</div><!-- .entry-content -->
我正在使用 jquery 来悬停图像,这很好,但不是我上面发布的代码。工作代码是
$('div.thumb').mouseover(function() {
$('a', $(this).parent())
.css("color","black")
.css("background","#ff7f00");
$('.post-ut', $(this).parent())
.css("color","black")
.css("background","#ff7f00")
.find('a').css("color","black");
$('.entry-summary p', $(this).parent())
.css("color","black")
.css("background","#ff7f00");
});
$('div.thumb').mouseout(function() {
$('a', $(this).parent())
.css("color","white")
.css("background","black");
$('.post-ut', $(this).parent())
.css("color","white")
.css("background","black")
.find('a').css("color","white");
$('.entry-summary p', $(this).parent())
.css("color","white")
.css("background","black");
});
更新:删除位置后:相对;从课后,悬停的作品,但文字不可见