Css 显示文件夹php中的图像(水平)
我有这个代码来显示文件夹中的图像,但问题是它垂直显示图像,有9000个图像,所以滚动结束 我想知道是否有可能使图像水平 我使用的代码是:Css 显示文件夹php中的图像(水平),css,Css,我有这个代码来显示文件夹中的图像,但问题是它垂直显示图像,有9000个图像,所以滚动结束 我想知道是否有可能使图像水平 我使用的代码是: <html> <head> <meta http-equiv="Content-Type" content="text/html"> <title>Show images in folder</title> <style type="text/css"> body { margin
<html>
<head>
<meta http-equiv="Content-Type" content="text/html">
<title>Show images in folder</title>
<style type="text/css">
body {
margin: 0 auto 20px;
padding: 0;
background: #acacac;
text-align: center;
}
td {
padding: 0 0 50px;
text-align: center;
font: 9px sans-serif;
}
table {
width: 100%;
}
img {
display: block;
margin: 20px auto 10px;
max-width: 900px;
outline: none;
}
img:active {
max-width: 100%;
}
a:focus {
outline: none;
}
</style>
</head>
<body>
<?php
$folder = 'album1584/';
$filetype = '*.*';
$files = glob($folder.$filetype);
$count = count($files);
$sortedArray = array();
for ($i=0; $i<count($files); $i++) {
$sortedArray[date ('YmdHis', filemtime($files[$i]))] = $files[$i];
}
krsort($sortedArray);
echo '<table>';
foreach ($sortedArray as &$filename) {
#echo '<br>' . $filename;
echo '<tr><td>';
echo '<a name="'.$filename.'" href="#'.$filename.'"><img src="'.$filename.'" /></a>';
echo substr($filename,strlen($folder),strpos($filename, '.')-strlen($folder));
echo '</td></tr>';
}
echo '</table>';
?>
</body>
</html>
尝试更改显示:块;显示:内联块;根据img标签的样式
编辑:
好的,我想我知道问题出在哪里了。您将每个图像放在一个单独的表行中,所以尝试将更多图像放在一行中,或者不使用表,而是使用我给您的css更改的简单容器 图像垂直列出,因为它们包含在表的各个行中。此外,在CSS中,您将它们设置为显示为块 删除显示:图像块,不要将它们放在表格中
另外,不要一次显示9000个图像。使用分页。是否确实要在一页上显示9000个图像?不要使用表格。为每个图像插入表行。这使文本水平,而不是图像。顺便说一下,谢谢你花时间回答