ListView 적용후 그림들이 겹쳐져서 보입니다.. 어느 부분이 잘못되있는지 문의드립니다.
1. articleapp/templates/articleapp/list.html
{% extends 'base.html' %}
{% load static %}
{% block content %}
<style>
.container div {
width: 250px;
background-color: antiquewhite;
display: flex;
justify-content: center;
align-items: center;
border-radius: 1rem;
}
.container img {
width = 100%;
border-radius: 1rem;
}
</style>
{% if article_list %}
<div class="container">
{% for article in article_list %}
<a href = "{% url 'articleapp:detail' pk=article.pk %}">
{% include 'snippets/card.html' with article=article %}
</a>
{% endfor %}
</div>
<script src="{% static 'js/magicgrid.js' %}"></script>
{% else %}
<div style="text-align:center">
<h1> Articles YET </h1>
</div>
{% endif %}
{% include 'snippets/pagination.html' with page_obj=page_obj %}
<div style="text-align:center">
<a href="{% url 'articleapp:create' %}" class="btn btn-dark rounded-pill col-3 mt-3 mb-3">
Create Article
</a>
</div>
{% endblock %}
pragmatic/templates/snippets/card.html
<div>
<img src="{{ article.image.url }}" alt="">
</div>
pragmatic/static/js/magicgrid.js
var masonrys = document.getElementsByTagName('img');
for (let i = 0; i< masonrys.length; i++) {
masonrys[i].addEventListener('load', function() {
magicGrid.positionItems();
}, false);
}
magicGrid.listen();