douzhuoxia0587 2016-12-23 12:50
浏览 110

如何为缩略图中的每个项目制作缩略图背景图像

I have a carousel with four items for which each should display an image covering the background in full width. How can I set the post-thumbnail image to a background image as it does apparently not recall the css?

CSS

#services .item:nth-child(1) {
background-position: center;
background-repeat: no-repeat;
background-attachment: scroll !important;
background-size: cover !important;
width: 100%; }

HTML/PHP

     <section id="services" class="services"><h1>What We Offer</h1>

        <div class="products" >
            <div class="carousel slide carousel-fade" id="carousel2" data-ride="carousel">
                <div class="carousel-inner">
            <?php
            $i=1;
            $the_query = new WP_Query(array(
            ‘category_name’ => ‘Cars’,
            ‘post_per_page’ => 4,
            'tag' => 'services'

            ));
            while ( $the_query->have_posts() ) :$the_query->the_post();if($i % 2 != 0){  ?>
            <div class="item services active ">
<?php if (the_post_thumbnail()) : ?>
    <div class="item services active">
    <?php the_post_thumbnail(); ?>
    </div>
<?php endif; ?>
                <div class="content-left">
                    <div class="text-center">
                    <h3><?php the_title();?></h3>
                    <h2 class="text-center"><?php the_content();?></h2>
                    </div>
                </div>
            </div>

            <?php }
            else { ?>
            <div class="item services">
<?php if (the_post_thumbnail()) : ?>
    <div class="item services">
    <?php the_post_thumbnail(); ?>
    </div>
<?php endif; ?>                    
                <div class="content-right">
                    <div class="text-center">
                    <h3><?php the_title();?></h3>
                    <h2 class="text-center"><?php the_content();?></h2>
                    </div>
                </div>
            </div>
            <?php } $i++; endwhile; wp_reset_postdata();?>
                    </div>
                </div>
            </div>
    

    <a class="left carousel-control" data-slide="prev" href="services #carousel2" role="button" >
      <span class="glyphicon glyphicon-menu-left"></span>
    </a>
    <a class="right carousel-control" data-slide="next" href="services #carousel2" role="button" >
      <span class="glyphicon glyphicon-menu-right"></span>
    </a>
            <ol class="carousel-indicators">
                <li data-target="services #carousel2" data-slide-to="0" class="active"></li>
                <li data-target="services #carousel2" data-slide-to="1"></li>
                <li data-target="services #carousel2" data-slide-to="2"></li>
            </ol>

        </section><!--#services -->

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)