第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Bootstrap > Carousel > 需要匹配圖像的指標(biāo)數(shù)量

Bootstrap > Carousel > 需要匹配圖像的指標(biāo)數(shù)量

PHP
holdtom 2022-11-04 16:39:41
我正在嘗試創(chuàng)建一個(gè)輪播滑塊,并使用 Bootstrap + 高級(jí)自定義字段使其工作。一切正常,但是我不知道如何使指標(biāo)與我擁有的圖像數(shù)量相匹配。因?yàn)樗菫槊總€(gè)圖像單獨(dú)編寫(xiě)的。我不擅長(zhǎng) JS,這就是我使用 Bootstrap 采用這種方法的原因。至于 ACF,我使用的是 Repeater 和 Image 的一個(gè)子字段(甚至我稱它為畫(huà)廊;))幫助將被appriciated。some CSS code here    <div class="container">    <div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="false">        <!-- Indicators -->        <ol class="carousel-indicators">          <li data-target="#myCarousel" data-slide-to="0" class="active"></li>          <li data-target="#myCarousel" data-slide-to="1"></li>          <li data-target="#myCarousel" data-slide-to="2"></li>        </ol>            <!-- Wrapper for slides -->        <div class="carousel-inner">                <?php            if( have_rows('aa-gallery') ):                $count = 0;                while ( have_rows('aa-gallery') ) : the_row();                ?>                    <div class="item <?php if (!$count) {                    ?>active<?php                   } ?>">                        <img src="<? the_sub_field('aa-gpic');?> " alt="<? the_sub_field('aa-caption');?>" style="width: 100%;">                            <div class="carousel-caption">                                <h3>                                    <?php the_sub_field('aa-caption'); ?>                                </h3>                            </div>                        </div>                    <?                                $count++;                endwhile;                        else :                            // no rows found                        endif;                        ?>          </div></section>
查看完整描述

1 回答

?
素胚勾勒不出你

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超9個(gè)贊

最簡(jiǎn)單的解決方案可能是使用 PHP 作為指標(biāo),就像使用它來(lái)列出 cariousel 項(xiàng)目本身一樣:


<div class="container">

    <div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="false">

        <?php if( have_rows('aa-gallery') ): ?>

          <!-- Indicators -->

          <ol class="carousel-indicators">

            <?php

              $count = 0;

              while ( have_rows('aa-gallery') ) : the_row();

            ?>

            <li data-target="#myCarousel" data-slide-to="<?php echo $count; ?>" class="<?php if (!$count) {

                      ?>active<?php 

                    } ?>"></li>

            <?php

              $count++;

              endwhile;

            ?>

          </ol>


          <!-- Wrapper for slides -->

          <div class="carousel-inner">


              <?php

                  $count = 0;

                  while ( have_rows('aa-gallery') ) : the_row();

                  ?>

                      <div class="item <?php if (!$count) {

                      ?>active<?php 

                    } ?>">

                          <img src="<? the_sub_field('aa-gpic');?> " alt="<? the_sub_field('aa-caption');?>" style="width: 100%;">

                              <div class="carousel-caption">

                                  <h3>

                                      <?php the_sub_field('aa-caption'); ?>

                                  </h3>

                              </div>

                          </div>

                      <?


              $count++;

              endwhile;

              ?>

            </div>


          <!-- Left and right controls -->

          <a class="left carousel-control" href="#myCarousel" data-slide="prev">

            <span class="glyphicon glyphicon-chevron-left"></span>

            <span class="sr-only">Previous</span>

          </a>

          <a class="right carousel-control" href="#myCarousel" data-slide="next">

            <span class="glyphicon glyphicon-chevron-right"></span>

            <span class="sr-only">Next</span>

          </a>

        <?php endif; ?>

  </div>

</div>

對(duì)于 JS 中更優(yōu)雅的解決方案,在初始化滑塊之前,您應(yīng)該計(jì)算項(xiàng)目的數(shù)量,然后用匹配的元素?cái)?shù)量填充指標(biāo)列表。但是上面的代碼也應(yīng)該足夠好用。


查看完整回答
反對(duì) 回復(fù) 2022-11-04
  • 1 回答
  • 0 關(guān)注
  • 120 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)