【发布时间】:2017-04-23 15:27:07
【问题描述】:
我需要从文件上传图像并按行显示。 我下面的代码显示一个在另一个之下的图像,而我希望它们在每行中显示为 3/4 个图像。
这是我尝试过的:
<html>
<head>
<title>Images in a Row</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="<?php echo base_url("assets1/css/bootstrap.css"); ?>">
</head>
<body>
<div class="container">
<p><?php echo $this->session->flashdata('statusMsg'); ?></p>
<form enctype="multipart/form-data" action="" method="post">
<div class="form-group">
<label>Choose Files</label>
<div id="rowimg">
<input type="file" class="form-control" name="userFiles[]" multiple/>
</div>
</div>
<div class="form-group">
<input class="form-control" type="submit" name="fileSubmit" value="UPLOAD"/>
</div>
</form>
<div class="row">
<div class="col-md-4">
<div class="thumbnail">
<?php if(!empty($files)): foreach($files as $file): ?>
<img src="<?php echo base_url('uploads/files/'.$file['file_name']); ?>" alt="" >
<p>Uploaded On <?php echo date("j M Y",strtotime($file['created'])); ?></p><br>
<?php endforeach; else: ?>
<p>Image(s) not found.....</p>
<?php endif; ?>
</div>
</div>
</div>
</div>
</body>
</html>
我在 StackOverflow 中研究了一些解决方案并获得了 CSS 代码,但它为我提供了相同的输出,所有图像一个在另一个之下:(
CSS 文件:bootstrap.css
#rowimg {
white-space: nowrap;
width: 5000px;
height:200px;
}
【问题讨论】:
-
在没有引导 css 的情况下使用引导类将是首先修复
-
我在此处粘贴代码时跳过了引导类链接。
-
你能发布从
containerdiv开始的渲染HTML代码吗? -
哦,在那种情况下,我看到你有一个结束
</a>但我没有看到任何开口<a>- 这让我想知道浏览器是如何呈现的。 -
@DanPhilip 请原谅我的不便,因为我是新手,我不知道 HTML 的渲染是如何完成的。如果你能指导我,我会做的。
标签: php html css twitter-bootstrap