【发布时间】:2018-02-07 21:39:58
【问题描述】:
大家好,感谢您的宝贵时间
请帮助我修复下面的 html 代码,我试图在每次用户/浏览器刷新页面时实现图像刷新(随机顺序),此时它工作正常。但是图像不会自动调整大小以适应屏幕,换句话说,如果图像大于屏幕,那么我必须向下/向右滚动才能看到图像,请帮我解决这个问题,让我抓狂
我要文件夹叫 domain.com/index.php 包含所有图像的 domain.com/images 文件夹
<!DOCTYPE html>
<html>
<body style="background-color:transparent;">
<style type="text/css">
.myImage
{
// margin: auto;
// display: block;
height: auto;
width: auto;
// padding: 0px;
//object-fit: contain
// overflow-x: auto;
// white-space: nowrap;
}
</style>
<?php
$folder = opendir(images);
$i = 0;
while(false !=($file = readdir($folder))){
if($file != "." && $file != ".."){
$images[$i]= $file;
$i++;
}
}
$random_img=rand(0,count($images)-1);
echo '<img src="images/'.$images[$random_img].'" alt="image" class="myImage" ';
?>
</body>
</html>
【问题讨论】:
-
你能澄清一下这个问题吗?不清楚你想要什么。