dougou8458 2013-12-16 22:18
浏览 34
已采纳

CSS3列垂直跨越

I'm making a basic columns layout for photos with CSS3 Columns,

the problem is that in this way, it will first align content vertically and and then go to next column

for example consider this: http://jsfiddle.net/LQEfK/1/

here as you can see first second and third img are in first column. I found -webkit-column-axis which is not much documented and is suported only by Chrome.

<div class="image-gallery main">
    <?php while ( bp_has_images() ) : bp_the_image(); ?>
        <div class="image-thumb-box">
            <img alt="<?php bp_gallplus_image_id() ?>" src="<?php bp_image_mid_url() ?>" alt="">
        </div>
    <?php endwhile; ?>
</div>

Now I want to remake this php to align with this CSS. Like save make 3 variables in while loop and each should contain a column which will be right for css columns

  • 写回答

2条回答 默认 最新

  • douyu4535 2013-12-16 23:30
    关注

    Here is what I've done;

    <div class="image-gallery main">
        <?php
            $key = 1;
            $column_one = '';
            $column_two = '';
            $column_three = '';
        ?>
        <?php while ( bp_gallplus_has_images() ) : bp_gallplus_the_image(); ?>
            <?php
    
                if($key == 1) {
                    $column_one .= '<img data-postid="'. bp_gallplus_get_image_id() .'" data-org="'. bp_gallplus_get_image_url() .'" class="media-popover" data-pop="popover" src="'. bp_gallplus_get_image_mid_url() .'" alt="">';
                    $key++;
                } else if ($key == 2) {
                    $column_two .= '<img data-postid="'. bp_gallplus_get_image_id() .'" data-org="'. bp_gallplus_get_image_url() .'" class="media-popover" data-pop="popover" src="'. bp_gallplus_get_image_mid_url() .'" alt="">';
                    $key++;
    
                } else {
                    $column_three .= '<img data-postid="'. bp_gallplus_get_image_id() .'" data-org="'. bp_gallplus_get_image_url() .'" class="media-popover" data-pop="popover" src="'. bp_gallplus_get_image_mid_url() .'" alt="">';
                    $key = 1;
                }
            ?>
        <?php endwhile; ?>
        <?php echo $column_one . $column_two . $column_three; ?>
    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化