inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

작정하고 장고! Django로 Pinterest 따라만들기 : 바닥부터 배포까지

ListView, Pagination 소개 및 적용

ListView 적용후 게시물이 겹쳐보이는 현상 관련 문의드립니다.

272

유형주

작성한 질문수 10

0

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 = 0imasonrys.lengthi++) {
    masonrys[i].addEventListener('load'function() {
        magicGrid.positionItems();
    }, false);
}

magicGrid.listen();
 

docker python django

답변 2

0

유형주

감사합니다 ㅎㅎ.. 역시 오타 문제였군요

0

Hyong Sok Park

안녕하세요.
질문 확인했습니다.

작성하신 코드 중에 에러가 CSS 부분에 있는것 같습니다.

<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>

 

위 부분 중에서 

    .container img {
        width = 100%;
        border-radius: 1rem;
   }

이 부분을 보시면 width = 100% 라고 적혀있는데,
해당 부분을 width: 100% 로 변경해주시길 바랍니다.

CSS 구문 오류로 인해서
이미지의 크기가 100% 가 아니라
해당 이미지의 사이즈를 그대로 출력해서
생기는 문제로 보입니다.


답변이 도움이 되셨길 바랍니다!
좋은하루 보내시구요-
감사합니다-

강의에 나왔던 js 파일이 깃허브에 없습니다

1

78

1

모바일 디버깅, 반응형 레이아웃 4분48초 질문

0

57

1

decorator 관련질문입니다.

0

63

1

PasswordChangeView

0

104

2

로그아웃뷰 작동 관련 (2025년 3월)

1

138

1

실행에러질문

0

159

1

@login_required 데코레이터 사용시 리다이렉트는 어디서 참조하여 설정을 하는걸까요?

0

116

1

CacheBackend 관련 에러

0

181

1

21강 CreateView를 통한 회원가입 구현 질문

0

325

1

53강 disallowedhost

0

346

2

502 Bad Gateway

0

474

0

mariadb 접근권한 오류

0

544

1

logout 후 빈 화면으로 이동합니다 ㅠㅠ

0

461

2

로그아웃 후 빈 화면으로 이동

0

333

1

서버 운영 관련 질문 드립니다.(Unable to retirve...)

0

232

1

static/base.css파일을 인식을 못합니다

0

381

1

안녕하세요 19강 디버깅 설정 질문있습니다.

0

291

1

프로필 update편 질문있습니다.

0

380

1

수업질문

0

395

1

COOP error

0

531

1

61강 Dockerfile error

0

598

1

static안에 base.css 에서 정의한 클래스가 적용되지 않습니다.

0

491

1

static 파일 중 jpg 파일만 로드 불가

0

419

1

58강 static 파일 적용 안됨

0

547

1