【发布时间】:2016-01-25 05:30:15
【问题描述】:
我的目标:制作一个可以从浏览器打印为 PDF 的基本图片库,作为 8.5" x 11" 纵向布局的 3col x 4row 网格。图片 URL 和简短描述来自 django 应用程序,因此我既不知道将查看多少张图片,也不知道它们的文件名。
以下代码基于http://www.w3schools.com/css/css_inline-block.asp
它会生成一个图片库,其结果可以在此处作为屏幕截图看到:
我的问题:有没有办法让盒子保持在固定的网格中?一些盒子被推到了不合适的地方,但我不知道为什么。如果有更好的解决方案,我希望你能指出我。
谢谢!
<!DOCTYPE html>
<html>
<head>
<style>
.floating-box {
display: inline-block;
width: 150px;
height: 180px;
margin: 1px;
border: 1px solid #73AD21;
}
.text-box {
font-size: 9px;
border: 1px solid blue;
}
</style>
</head>
<body>
<div>
<h3>Section 14: Attachments</h3>
{% for inspectionfeedback in inspection.inspectionfeedback_set.all %}
{% if inspectionfeedback.feedback_image.path == "" %}
{% else %}
<div class="floating-box">
<img src="{{ inspectionfeedback.feedback_image.url }}" style="width:140px;" alt=" " >
<div class="text-box">
{{ inspectionfeedback.feedback_inspection_item }}
</div>
</div>
{% endif %}
{% endfor %}
</div>
</body>
</html>
【问题讨论】: