Php 如何将jpg文件上载到一个常见的长水平图像中?

Php 如何将jpg文件上载到一个常见的长水平图像中?,php,html,css,Php,Html,Css,我写了一个图像库,不使用任何库。我从特定目录上传jpg文件。我想将上传的“uniq_图像”图像组合成一个长的水平图像“moving_图像”,以便将它们滚动到一起 css文件: //the common long horizontal image that I want to assemble from uniq_images #moving_image { background-repeat: no-repeat; position: relative; border

我写了一个图像库,不使用任何库。我从特定目录上传jpg文件。我想将上传的“uniq_图像”图像组合成一个长的水平图像“moving_图像”,以便将它们滚动到一起

css文件:

//the common long horizontal image that I want to assemble from uniq_images
#moving_image  {
    background-repeat: no-repeat; 
    position: relative;
    border:1px dashed red;
    width: 420px;
    height: 130px;
    left: 10px;
    overflow:hidden;
}
//the style for each uploaded image from the file
#uniq_image {
    background-repeat: no-repeat;
    border:1px solid blue;
    width: 150px;
    height: 120px;
    overflow:hidden;
}
包含php上载代码的html文件:

....
<td width ="420" height="130" overflow="hidden">
     <div id= "moving_image" >
         <?php
             $img_folder = 'picture';
             $dir = dir($img_folder);
             while (($file = $dir->read()) !== false){
                 echo '<img src="'.$img_folder."/".$file.'" style="uniq_image" >';
             }
            $dir->close();
          ?>
      </div>
<td>
。。。。

我错过了什么?谢谢。

你似乎只遗漏了最基本的东西

您应该使用
.uniq\u image
定义类样式<代码>#uniq_image是一个ID规则,不能有多个元素具有相同的ID

并将
style=“uniq\u image”
更改为
class=“uniq\u image”
style
属性用于定义内联样式规则


可能还有其他问题,但从这些变化开始。另外,在开始实施这样的事情之前,请考虑更多的阅读,因为你把所有的东西都混在一起了。< / P >嗨,Alin Purcaru。你说得对,谢谢。它看起来好多了,但我还是有一个小问题。在“移动图像”中,只有部分上传的“uniq_图像”。在“移动图像”中,只有5个图像,而不是14个图像。我删除了“moving_image”定义中的“overflow:hidden”,但是bug仍然存在。你知道我怎样才能插入所有图像而不是只插入5个吗?@tatiana_c你在
td
上还有
overflow=hidden
。我也注意到了这一点。但是,如果我从“td”定义中删除“溢出:隐藏”,图像不会被包装到单元格中,单元格的大小是巨大的,而不是420px。我想我问的另一个问题与问题的主题不同。也许我会问另外一个问题。非常感谢,这对我很有帮助。如果您试图从许多图像中创建一个高图像,将它们堆叠在一起,然后尝试按您想要的方向浮动所有图像,同时在通话后立即清除浮动。这将导致它们不是并排排列,而是堆叠。也就是说,你的img类将有float:right,然后紧接着在同一类的下方,清除:float