【发布时间】:2019-07-14 10:22:51
【问题描述】:
我目前正在为我的博客开发一个主题,我有一个关于在 Wordpress 中集成 Carousel Slider 的问题。
滑块效果很好,显示最新的 5 篇帖子,带有特色图片和带有帖子标题的标题。但是我不得不为img设置一个固定的高度,因为不同大小的图像会不断改变轮播的高度,所以结果不是很好。
问题是在移动设备上img拉伸很多,所以我想将帖子缩略图设置为轮播的背景,这样我可以设置bg-size,bg-position等以实现完美响应式图片。
你知道有没有办法达到这个目标?或者也许我的实际代码可以在不将缩略图设置为背景的情况下使用?
提前谢谢大家。
<div class="carousel-inner">
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php $active_class = ( 0 === $the_query->current_post ) ? ' active': ''; ?>
<div class="carousel-item <?php echo esc_attr( $active_class ); ?>">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail('full') ?>
</a>
<div class="carousel-caption d-md-block">
<h2><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h2>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
</div>
【问题讨论】:
标签: wordpress twitter-bootstrap