我写了一个图片库,我不使用任何库。我从特定目录上传 jpg 文件。我想将上传的“uniq_image”图像组合成一个长的水平图像“moving_image”,以便将它们一起滚动
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_image
定义类样式。 #uniq_image
是一个 ID 规则,您不能有多个具有相同 ID 的元素。
并将 style="uniq_image"
更改为 class="uniq_image"
。 style
属性用于定义内联样式规则。
可能还有其他问题,但从这些更改开始。另外,在开始实现此类内容之前,请考虑多读一些书,因为您把所有内容都搞混了。
关于php - 如何将jpg文件上传到一张普通的长横图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9039116/