admin管理员组文章数量:1395897
I'm putting together a blog in Django(v4x) and trying to use TailwindCSS v4 to list out the blog posts in a column template, 3 across. They list out 3, going down, not across, what am I doing wrong?
Here is what I have in my blog index.html Django html template
{% block content %}
<div class="border-8 border-purple-900">
<h1>Articles</h1>
<div class="grid grid-cols-3 gap-4">
<div>01</div>
<div>02</div>
<div>03</div>
<div>04</div>
<div>05</div>
<div>06</div>
<div>07</div>
<div>08</div>
<div>09</div>
</div>
{% for post in posts %}
<div class="grid grid-cols-3 gap-1">
<div class="border-4 border-black">
<article>
<h1 class="text-2xl font-semibold">
<a href="{% url 'blog:blog_detail' post.slug %}">{{ post.title }}</a>
</h1>
<h4>{{ post.created_at.date }}</h4>
<!-- <p>{{ post.author }}</p> -->
<div>{{ post.content | slice:":50" }}...</div>
</article>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
I even copy+pasted the html from Tailwind docs page and it seems like it should work. What am I doing wrong?
I'm putting together a blog in Django(v4x) and trying to use TailwindCSS v4 to list out the blog posts in a column template, 3 across. They list out 3, going down, not across, what am I doing wrong?
Here is what I have in my blog index.html Django html template
{% block content %}
<div class="border-8 border-purple-900">
<h1>Articles</h1>
<div class="grid grid-cols-3 gap-4">
<div>01</div>
<div>02</div>
<div>03</div>
<div>04</div>
<div>05</div>
<div>06</div>
<div>07</div>
<div>08</div>
<div>09</div>
</div>
{% for post in posts %}
<div class="grid grid-cols-3 gap-1">
<div class="border-4 border-black">
<article>
<h1 class="text-2xl font-semibold">
<a href="{% url 'blog:blog_detail' post.slug %}">{{ post.title }}</a>
</h1>
<h4>{{ post.created_at.date }}</h4>
<!-- <p>{{ post.author }}</p> -->
<div>{{ post.content | slice:":50" }}...</div>
</article>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
I even copy+pasted the html from Tailwind docs page and it seems like it should work. What am I doing wrong?
Share Improve this question asked Mar 14 at 18:08 user3125823user3125823 1,9023 gold badges18 silver badges47 bronze badges1 Answer
Reset to default 2You'd want to have the grid
wrapper outside the foreach loop:
<div class="grid grid-cols-3 gap-1">
{% for post in posts %}
<div class="border-4 border-black">
<article>
<h1 class="text-2xl font-semibold">
<a href="{% url 'blog:blog_detail' post.slug %}">{{ post.title }}</a>
</h1>
<h4>{{ post.created_at.date }}</h4>
<!-- <p>{{ post.author }}</p> -->
<div>{{ post.content | slice:":50" }}...</div>
</article>
</div>
{% endfor %}
</div>
本文标签: djangoTailwindcss v4 Grid columnsStack Overflow
版权声明:本文标题:django - Tailwindcss v4 Grid columns - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744637915a2616935.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论