2012-12-27 12 views
0

我有多个图像(50x50),我的网站宽度是980像素如何让图像填充100%的div如果“他们不适合”

我想用图像填充一行,没有任何差距。但是,如果没有任何CSS/JS /帮助,第20张图片就会排在第二排。

如何显示第20张图像的40%?

+0

你想这样做,没有我的帮助?不可能! – niaher

回答

0

我自己找到了解决方案。

使用CSS来显示较短的宽度:

<?php 
    $img = ""; 
    $width = 50; 
    for($i=0;$i<20;$i++) { 
     if($i == 19) { 
      $width = 30; 
     } 
?> 
<img src="<?=$img;>" style="width: <?=$width;?>px; height:50px;" /> 
<?php 
    } 
?> 
+0

但你说'没有任何CSS/JS /帮助' – seanjacob

4

在您container格:

#container{ 
    overflow:hidden; /* Hide the overflow */ 
} 
0
img:nth-child(20n) { width:30px; }