我希望nth-child调整图像和文本标题的大小,nth-child完美地用于图像拇指但不用于文本标题。谁能帮助我哪里错了?提前谢谢。
<div id="programet" class="shadow">
<a href="/category/vendi" class="sfond_vendi">LAJME</a>
<?php
global $post;
$args = array( 'numberposts' => 22, 'order' => 'ASC', 'category' => 9 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<div id="lajme-bllok-item-vogel">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('lajmi-thumb'); ?></a>
<div id="lajme-bllok-item-title-vogel"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<div id="top-news-title-linku"><?php for( $i=1; $i<=4; $i++){ $prop_det_url = get_field('link'.$i); if( $prop_det_url != '' ){ ?>
<a href="<?php echo $prop_det_url; ?>" target="_blank">/ <?php the_field('link_titull'.$i); ?></a> <?php } } ?></div>
</div>
<?php endforeach; ?>
</div>
#lajme-bllok-item-vogel:nth-child(3n+1){width:auto;height:auto;float:left;margin:0 0 0 0;padding:25px 10px;border-bottom:1px solid #ddd;}
#lajme-bllok-item-vogel:nth-child(3n+1) img{height:219px;width:390px;border-top:2px solid #F00;box-shadow:0 0 10px rgba(0, 0, 0, 0.5);}
#lajme-bllok-item-title-vogel:nth-child(3n+1) {width:368px;height:auto;margin:-6px 0 0 0;padding:11px;box-shadow:0 0 10px rgba(0, 0, 0, 0.5);font:21px/23px 'lato-bold',Arial,'Helvetica Neue',Helvetica,sans-serif;font-size:21px;font-weight:bold;}
#lajme-bllok-item-title-vogel:nth-child(3n+1) a:hover{color:#01628F;}
答案 0 :(得分:1)
这是因为您正在迭代顶级项目,应该对此应用nth-child
选择,但是您的CSS正在将nth-child
选择应用于其子级。您想将选择器更改为以下内容。
变化:
#lajme-bllok-item-title-vogel:nth-child(3n+1) {width:368px;height:auto;margin:-6px 0 0 0;padding:11px;box-shadow:0 0 10px rgba(0, 0, 0, 0.5);font:21px/23px 'lato-bold',Arial,'Helvetica Neue',Helvetica,sans-serif;font-size:21px;font-weight:bold;}
#lajme-bllok-item-title-vogel:nth-child(3n+1) a:hover{color:#01628F;}
要
#lajme-bllok-item-vogel:nth-child(3n+1) #lajme-bllok-item-title-vogel {width:368px;height:auto;margin:-6px 0 0 0;padding:11px;box-shadow:0 0 10px rgba(0, 0, 0, 0.5);font:21px/23px 'lato-bold',Arial,'Helvetica Neue',Helvetica,sans-serif;font-size:21px;font-weight:bold;}
#lajme-bllok-item-vogel:nth-child(3n+1) #lajme-bllok-item-title-vogel a:hover{color:#01628F;}
顺便说一句,看起来您还在复制id
代码,应该避免这种情况 - id
属性必须是唯一的。