首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iDangero.us的中心幻灯片不起作用的缩略图

iDangero.us的中心幻灯片不起作用的缩略图
EN

Stack Overflow用户
提问于 2016-03-20 22:54:19
回答 1查看 2.2K关注 0票数 0

我正在使用iDangero.us插件的Swiper。我创建的布局包含6个滑块图像和6个缩略图。

不知怎么的,如果我让缩略图以中心对齐,插件就会变得一团糟。为此,我将centeredSlides变量更改为false

这里有一个JSFiddle:https://jsfiddle.net/fa4218de/5/

有人能帮我修一下这个吗?或者有什么解决办法。

Swipper文档

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-21 01:13:12

万一有人需要答案的话。我创建了自己的解决方案,通过将缩略图链接到单个酒杯,并根据缩略图的子编号旋转它们。下面是密码。

THE JS

代码语言:javascript
复制
jQuery(document).ready(function($) {

    var galleryTop = new Swiper('.gallery-top', {
        paginationClickable: true,
        nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev',
        spaceBetween: 30,

    });

    // Make first child of div active
    $(".portfolios-thumb-wrapper .container .row div:first-child").addClass("active");


    // When click on any of the thumbnails with classname 'slide_no' it 
    // gets the child number of the div and then I just use that number
    // to rotate to that specific slide number by 'slideTo' callback
    $('.slide_no').each(function (i) {
        $(this).click(function (e) {
            e.preventDefault();
            var thumb = i;
            galleryTop.slideTo( thumb,1000,false );
            $('.slide_no').removeClass('active');
            $(this).addClass('active');

        });
    });
});

带有 (WordPress)的WordPress,以防您需要获得和理解标记

代码语言:javascript
复制
<div class="portfolios-wrapper">
<?php   if ( $postslist->have_posts() ) : ?>
        <div class="swiper-container gallery-top">
            <div class="swiper-wrapper gallery_top_slides">

        <?php while ( $postslist->have_posts() ) : $postslist->the_post(); ?>

                <?php 
                $post_id            = $post->ID;
                $permalink          = get_post_permalink( $post_id );
                $backgroundImage    = get_post_meta( $post_id, 'portfolio_background_image', true );

                ?>

                <div class="swiper-slide top_slide_<?php echo $top_counter;?>" style="background-image: url('<?php echo $backgroundImage; ?>');">

                    <div class="portfolio-details" style="background-color:transparent">
                        <div class="container" style="background-color:transparent">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="portfololio-thumb">
                                        <?php echo the_post_thumbnail( 'large' );?>
                                        <?php echo the_title( '<h2>', '</h2>', true );?>
                                    </div>
                                </div>

                                <div class="col-md-6">

                                    <div class="portfololio-excerpt">
                                        <?php echo the_title( '<h2>', '</h2>', true );?>
                                        <p><?php echo get_the_date( 'M Y' ); ?></p>
                                        <span class="excerpt"><?php echo the_excerpt(); ?></span>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>

        <?php $top_counter++; endwhile; ?>
            </div>
            <div class="container custom_adjust">
                <div class="swiper-button-next custom-btn-next">Next</div>
                <div class="swiper-button-prev custom-btn-prev">Previous</div>
            </div>
        </div>
<?php   endif; ?>
</div> 

<div class="portfolios-thumb-wrapper">
<?php   if ( $postslist->have_posts() ) : ?>
        <div class="container">
                <div class="row">

            <?php while ( $postslist->have_posts() ) : $postslist->the_post(); ?>

                    <?php if (has_post_thumbnail( $post->ID ) ): ?>
                        <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
                    <?php endif; ?>

                    <div class="col-md-2 slide_no">
                        <div class="thumb_slide" style="background-image: url(' <?php echo $image[0]; ?> ')">
                        </div>
                        <div class="portfolio-title"><?php echo the_title( '<h2>', '</h2>', true );?> </div>
                    </div>  

            <?php $thumb_counter++; endwhile; ?>
                </div>
        </div>

<?php   endif; ?> 
</div>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36120639

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档