php - 第 n 个 child 调整图像缩略图和标题的大小

标签 php css wordpress css-selectors

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

最佳答案

这是因为您正在迭代顶级元素并且应该对其应用 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 属性必须是唯一的。

关于php - 第 n 个 child 调整图像缩略图和标题的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22989961/

相关文章:

java - 如何从 PHP 应用程序与 Tomcat 服务器通信

javascript - 如何阻止 jQuery UI 对话框被压扁?

"big steps"的 CSS 线性渐变

css - Wordpress 水平滚动错误

php - URL 字符串中包含 "utm_"会破坏 Wordpress 中的 $_GET 变量

php - 如何使用php对sql表中的数字数据进行排序

php - 使用php从mysql中搜索数据

php - 为什么 gettype() 说它是 double 型而 var_dump() 说它是 float ?

html - 为什么out div的高度受vertical-align影响

javascript - 如何向现有的 jQuery AJAX 单击功能添加加载微调器