'How to display items in a row of 4 across using Django, HTML, and Python
This is my code. I want the items to be displayed horizontally. I've tried changing the col-md-3
and still no luck.
<title>Document</title>
</head>
<body>
<div class="container">
<div class="row">
{% for product in product_objects %}
<div class="col-md-3">
<div class="card">
<img src="{{ product.image }}" class="card-img-top">
<div class="card-body">
<div class="card-title">
{{ product.title }}
</div>
<div class="card-text">
{{ product.price }}
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</body>
</html>
Solution 1:[1]
Not sure why it's showing it correctly, but I changed:
<div class="container">
<div class="column">
to:
<div class="container">
<div class="row">
Now it's displaying correctly.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Salek |