简体   繁体   English

第n个孩子调整大小的图像缩略图和标题

[英]nth-child resize image thumbnail and title

I want to nth-child to resize image and text title, nth-child work perfectly for image thumb but not for text title. 我想让nth-child调整图像和文本标题的大小,nth-child非常适合图像缩略图,而不适合文本标题。 Can anyone help me where iam wrong? 谁能帮助我我错了? Thank you in advance. 先感谢您。

<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;}

Its because you're iterating the top level item and should be applying nth-child selection to this, however your CSS is applying nth-child selection to its child instead. 这是因为您要迭代顶级项,并且应该对此应用nth-child选择,但是CSS却将nth-child选择应用于其子项。 You want to change your selector to the below. 您想将选择器更改为以下内容。

Change: 更改:

#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;}

To

#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;}

Incidentally, it also looks like you are duplicating your id tags, you should avoid this- id attributes must be unique. 顺便说一句,看起来您正在复制id标记,您应该避免此id属性必须是唯一的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM