【问题标题】:Responsive Wordpress post thumbnail响应式 Wordpress 帖子缩略图
【发布时间】:2014-04-15 12:32:46
【问题描述】:

所以我有一个响应式作品集库,其中显示了我的作品集自定义帖子类型的所有特色图片。

在functions.php中,我将帖子缩略图大小设置为:

set_post_thumbnail_size( 960, 540, true )

该网站的最大宽度为 1920 像素,因此从技术上讲,因为它是一个两列画廊,所以图片永远不会超过一半。

在 chrome 上它看起来像我想要的那样,当浏览器变小时,图像会缩小到适当的大小。在 Internet Explorer 中,虽然它们没有响应,但有什么想法,以及如何解决它?

这是我画廊的 CSS:

@media screen and (min-width : 640px){

    .item{
        display:inline-block;
        clear:none;
    }

    .item:nth-child(odd){
        width:50%;
        float:left;
        clear:both;
    }
    .item:nth-child(even){
        width:50%;
        float:right;
    }
}

.img {
        position: relative;
}

这里是 html/php :

    <div class="item">
      <?php $site= get_post_custom_values('projLink'); 
        if($site[0] != ""){
      ?>        
        <div class="img">
          <a title="<?=$title?>" href="<?=$site[0]?>">
            <?php the_post_thumbnail(); ?>
          </a>
          <span class="itemTitle"><?php the_title(); ?></span>
        </div>
      <?php }
        else { ?>
           <p><em>You need to post your link.</em></p>
        <?php } ?>
   </div> 

【问题讨论】:

    标签: php wordpress thumbnails media


    【解决方案1】:

    尝试将图像的宽度显式设置为父级的 100%。

    像这样:

    .item img {
        position:relative;
        width: 100%;
    }
    

    编辑:不是类,是实际的图像标签。

    【讨论】:

      猜你喜欢
      • 2011-03-15
      • 1970-01-01
      • 2012-01-26
      • 1970-01-01
      • 2011-09-04
      • 2013-07-17
      • 2015-07-19
      • 1970-01-01
      • 2017-08-02
      相关资源
      最近更新 更多