-6

我有问题并没有解决。

What i want is that listing photos side to side 

像那样:

在此处输入图像描述

The problem is that when i have 50 photos , this happens

在此处输入图像描述

我想要的是每列列出十张照片。我怎样才能做到这一点 ?

4

1 回答 1

1

循环显示图像时,您需要每 10 张照片中断一次,如下所示:

$photosPerLine = 10;
for ( var $i = 0; $i < $totalNumPhotos; $i++ )
{
    drawPhoto();  // This does the actual drawing - perhaps echo a <IMG> or whatever

    // Now we check if we've reached 10 in a row, we do this by dividing the
    // photo counter by 10 and checking for a reminder, only numbers in leaps
    // of 10 will divide without a reminder.  If we don't have a reminder it means
    // we're at 10, 20, 30 ... so we break the line

    if ( ( $i + 1 ) % $photosPerLine == 0 )
    {
        echo( '<br/>' );  // Or create a new row in a table or whatever
    }
}

或者只是将图像放置在具有指定宽度的容器(<div>例如)中以恰好容纳 10 个图像,并让浏览器换行以适应内容。

于 2012-04-10T13:40:37.267 回答