我想在其DIV标签内的图像“folderContents05.jpg”顶部显示文件夹内容。 PHP脚本应该输出它所在目录的文件夹内容。脚本本身可以正常工作,但是当我在html中使用它或调用脚本时,我似乎无法显示任何内容。
这是HTML-
<head>
<title>index</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="style.css" rel="stylesheet" type="text/css">
<!-- End Save for Web Styles -->
</head>
<body style="background-color:#353535; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;">
<!-- Save for Web Slices (index.psd) -->
<div id="wrapper">
<div id="Table_01">
<div id="folderContents01">
<img src="images/folderContents01.jpg" width="359" height="120" alt="">
</div>
<div id="folderContents02">
<img src="images/folderContents02.jpg" width="591" height="150" alt="">
</div>
<div id="folderContents03">
<img src="images/folderContents03.jpg" width="359" height="30" alt="">
</div>
<div id="folderContents04">
<img src="images/folderContents04.jpg" width="126" height="460" alt="">
</div>
<div id="folderContents05">
<img src="images/folderContents05.jpg" width="698" height="396" alt="">
</div>
<div id="folderContents06">
<img src="images/folderContents06.jpg" width="126" height="460" alt="">
</div>
<div id="folderContents07">
<img src="images/folderContents07.jpg" width="698" height="64" alt="">
</div>
<div id="folderContents08">
<img src="images/folderContents08.jpg" width="950" height="90" alt="">
</div>
</div>
</div>
<!-- End Save for Web Slices -->
</body>
</html>
和php脚本
<?php
$count = 0;
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {$count++;
print("<a href=\"".$file."\">".$file."</a><br />\n");
}
}
closedir($handle);
}
?>
答案 0 :(得分:0)
你必须将“文件夹内容”图像作为div的背景并通过php本身生成HTML标记,如下面的代码
if ($file != "." && $file != "..") {$count++;
print(<div id="folderContents +i">
</div>)
并放置一个计数器,以便您可以使用它来生成(folderContents1,folderContents2等)。
答案 1 :(得分:0)
在style= "z-index: 0"
代码上使用<img>
并将PHP更改为:
<?php
$count = 0;
if ($handle = opendir('.')) {
echo '<div style="z-index: 1">';
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {$count++;
print("<a href=\"".$file."\">".$file."</a><br />\n");
}
}
echo '</div>';
closedir($handle);
}
?>
使用z-index建立元素'on-top-ness'的顺序
答案 2 :(得分:0)
这是你想要的吗?
<div id="folderContents05" style="position: relative">
<img src="images/folderContents05.jpg" width="698" height="396" alt="">
<div style="position: absolute; left: 0; top: 0; z-index: 100">
<?php
$count = 0;
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$count++;
print("<a href=\"".$file."\">".$file."</a><br />\n");
}
}
closedir($handle);
}
?>
</div>
</div>