Using random images from database to fill up whole web page height and width
I'd look to pull X number of images from my DB anything from 100 +/- images, and I'd like to take up the whole page 开发者_StackOverflow社区from top left corner to bottom right corner
so far i got this
<? $images .= "<img src='".$image."' width='64' height='64' style="float:left;"/>";?>
<div style="position: absolute; top:0px; left:0px;" ><?=$images;?></div>
But this code doesn't fill all the way to the right and bottom
This a NP-Hard problem. What you want is a greedy algorithm to fill each row of your screen with a random image when only the the width of your screen is the limiting value. I've written a bin-packing solution for this problem. You are welcome to download my package bin-packing at phpclasses.org.
I would look in to jQuery Masonry. It has the ability to fill a page by moving the div containers around to build a wall (as masonry implies). I think that's what you're going for, at least if they're all not 64/6x pixels (allows you to be flexible with image sizes).
Demo can be found here
Otherwise, you may just making each element display inline and allow the browser to populate the area.
精彩评论