繁体   English   中英

如何将变量的值增加 100?

[英]How to increase the value of a variable by 100?

我有一个 ACF 中继器,通过它我 output 卡。 为卡片添加了生成 animation。 我需要每张卡的 animation 延迟比前一个多 100。 我怎样才能做到这一点?

 <ul data-aos="zoom-in" class="cards-list"> <?php if (have_rows('cards')): while (have_rows('cards')): the_row(); $delay = 300; ?> <li data-aos-delay="<?php echo $delay?>"> <img src="<?php the_sub_field('card_icon'); ?>" alt=""> <h3> <?php the_sub_field('card_title'); ?> </h3> <p> <?php the_sub_field('card_text'); ?> </p> </li> <?php endwhile; endif; ?> </ul>

您可以在while循环之外定义$delay的初始值,然后在循环内增加它:

<?php if (have_rows('cards')) :
     $delay = 200;
     while (have_rows('cards')) : the_row();
       $delay += 100; ?>

注意初始值 200 而不是 300,因为第一张卡也会增加 100,以确保初始延迟为 300。

暂无
暂无

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

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