Unable to modify the positioning of a card in HTML within a Django framework

I am experiencing an issue with the alignment of post cards in the front end of my HTML. When I add multiple posts, the size and alignment of the cards become irregular; some are bigger while others are smaller. How can I ensure that each post card is the same size?

{

    % for post in posts %}
                    <div class="col-lg-9">
                      <!-- ROW -->
                      <div class="row ">
              
                          <div class="col-12 mb-2">
                              <div id = "clicked-post" class="card shadow-sm">
                    <div class="card-body">
                          <div class="card-title">
                              <h5>{{ post.title }} <br> Posted by: {{ post.created_by }} &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&      {% if post.created_by == user %}<a href="{% url 'delete_post' post_id=post.id %}">Delete</a> {% endif %} </h5> 
                          <h6>Posted at: {{post.created_at}}[UTC 0]</h6>
                      </div>
                      <div class="card-main">
                          {{post.description}}
                      </div>


                      <div class="card-body">
                        <form  action="{% url 'create_comment' post.pk %}" method="post">
                            <div class="input-group">
                                {% csrf_token %}
                                {{ comment_form.comment_text|attr:"class:form-control rounded-pill"|attr:"placeholder:Add a class comment" }}
                                <div class="input-group-append">
                                    <button class=" btn btn-circle" type="submit" id="button-addon2"><i class="fas fa-angle-double-right"></i>Submit</button>
                                </div>
                            </div>
                        </form>
                    </div>
                      

                    <div class="card-body">
                        {% for comment in contents %}
                            {% if comment.post == post %}
                            <div class="d-flex flex-row">
                                <p class='ml-2'><strong>{{ comment.user }}</strong>: {{ comment.comment_text}}</p>
                            </div>
                            {% endif %}
                        {% endfor %}
                    </div>

              </div>
                </div>
                      </div>
                  </div>
              {% endfor %}

Answer №1

Make sure to align your divs properly using spacing or tabs to easily identify any unclosed ones. It seems like you forgot to close the initial div with the class="card-body"

<div class="col-lg-9">
    <!-- ROW -->
    <div class="row ">
        <div class="col-12 mb-2">
            <div id = "clicked-post" class="card shadow-sm">
                <div class="card-body">
                    <div class="card-title">
                        <h5>{{ post.title }} <br> Posted by: {{ post.created_by }} &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp; {% if post.created_by == user %}<a href="{% url 'delete_post' post_id=post.id %}">Delete</a> {% endif %} </h5> 
                        <h6>Posted at: {{post.created_at}}[UTC 0]</h6>
                    </div>
                    <div class="card-main">
                        {{post.description}}
                    </div>
<!-- an additional </div> might be needed here to close the div-->
                    <div class="card-body">
                        <form  action="{% url 'create_comment' post.pk %}" method="post">
                            <div class="input-group">
                                {% csrf_token %}
                                {{ comment_form.comment_text|attr:"class:form-control rounded-pill"|attr:"placeholder:Add a class comment" }}
                                <div class="input-group-append">
                                    <button class=" btn btn-circle" type="submit" id="button-addon2"><i class="fas fa-angle-double-right"></i>Submit</button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="card-body">
                        {% for comment in contents %}
                            {% if comment.post == post %}
                            <div class="d-flex flex-row">
                                <p class='ml-2'><strong>{{ comment.user }}</strong>: {{ comment.comment_text}}</p>
                            </div>
                            {% endif %}
                        {% endfor %}
                    </div>
                </div>
            </div>
        </div>
    </div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I arrange individual events in agendaWeek view on FullCalendar.io and then merge them all into one line?

I am using Fullcalendar.io version 2 When I switch to the agendaWeek mode, all my events are displayed on one line in each day square. As a result, the more events I have, the thinner the event blocks become. Is there a way for me to display only one eve ...

Tips for implementing a custom filter in an AngularJS JavaScript controller

Can anyone help me with creating a custom filter in an AngularJS JavaScript controller? I need to be able to search for items in an array called segments by their SegmentId. The filter should iterate through the segments array and return the segment that ...

Is it feasible to generate a vertical bar or horizontal graph using Chart.JS?

Is there a way to manipulate Chart.JS to create a horizontal bar chart with percentages displayed along the bottom, similar to this example created using xlsxwriter? View Example UPDATE I marked a certain answer as correct based on the jsfiddle provided ...

Changing the div background color based on the status of the `.play()` function

I need assistance with changing the background color of a div based on whether an audio file is playing or not. $('.uprow2').on('click', function() { $('#karma')[0].play(); }); .uprow2 { width: 680px; height: 60px; ...

Developing alternatives for CSS Grid

Currently, I am faced with an intriguing challenge involving a layout that includes a container containing 9 div elements. Each of these divs is assigned one of three classes: column-1, column-2, or column-3. <div class="grid cols-3"> <div cl ...

Adjusting the Size of a Slideshow: HTML Tutorial

I'm currently working on a project to develop an interactive website using PHP and HTML for educational purposes. My main challenge is trying to implement a 'slideshow' similar to the one demonstrated in this video: https://www.youtube.com/ ...

Is there a way to align text and an image with the bottom line in HTML?

After running Code A, I am presented with Image A as the result. I am looking to align this text and image at the bottom line, similar to how it appears in Image B. How can I achieve this alignment? Code A <asp:Label ID="Label1" runat=" ...

The link only seems to function properly after being refreshed

I'm currently creating a mobile site using JQuery Mobile. I have multiple pages within my foobar.html and navigating like this: <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" ...

A guide on incorporating a countdown timer feature into your Django project

Currently, I am working on a sports application using Django and I need some guidance. The main functionality of the app involves measuring time and then displaying it to the user. In addition, during a countdown timer, there are certain actions that nee ...

Jekyll adjusting the starting line of code snippet formatting

Currently, I'm in the process of setting up code highlighting for my blog using Jekyll and Pygments. However, I'm facing an issue where the first line of every code snippet seems to be slightly offset. To create a gutter effect, I'm utilizin ...

"Utilizing Bootstrap to create proper spacing between elements within a

https://i.sstatic.net/ArC6C.png Hello there! I am looking for help on how to align my value 2 next to value 1 with some spacing, and also adjust the text "Lorem Ipsum" based on the size of my button. This is my current code: a <div classNa ...

Using Python with the lxml library to extract every item in a specific list

I'm trying to extract all the items from a list on a website Here is the HTML snippet I am working with: <ul> <li class="name"> James </li> <li> Male </li> <li> 5'8" </li> </ul> Curre ...

Play framework fails to apply style attributes correctly

When working with play-framework 2.3.x, I am in the process of creating a form and would like to show/hide it based on a model attribute. Typically, setting the style attribute manually using style = "display: none" and style = "display: block" works fine. ...

Having trouble eliminating the underline on Vue router-link?

I've experimented with various approaches in an attempt to remove the underline from router-link. This is the code I have: <router-link :to="{name: 'Plan'}"> <div>Plan Your Trip</div> <div class=&apos ...

Display or conceal DIVs with multiple attribute values according to the selected value in a dropdown menu using the jQuery Filter Method

I am attempting to display or hide multiple services, each with a custom attribute called data-serviceregion, which may have multiple values based on the selected option from the dropdown. <form class="book-now"> <select name="region" id="region" ...

The one-click button is functional on larger screens, while on mobile devices, only a double click will register

I am facing an issue in angular where a button works perfectly fine with one click on larger screens, such as Macbook. However, on iPhone, it requires a double click to function properly (it works fine on Android too). The alert triggers with a single cl ...

Tips for styling the edit, update, and delete buttons on a gridview using Bootstrap in an ASP.NET web form

I am currently working on a gridview in an ASP.NET web form that has edit, delete, and update buttons enabled. I am looking to customize the appearance of these buttons as they currently look like simple hyperlinks by default. Below is the code snippet fo ...

Display the Edit button only when the radio button has been selected

Need help with radio buttons and hidden edit links Radio1 Radio2 I have JQuery code that works well for showing and hiding Edit links when clicking on radio buttons. However, there is an issue where the default checked radio button does not display the ...

Show the res.send() method from express.js without replacing the existing html content

Currently, I am in the process of developing a calculator application using express.js. The app needs to handle get requests for an HTML file and post requests that capture user input and provide the response accurately. My challenge lies in showcasing the ...

Populating a drop-down menu using Python requests in a select tag

I am attempting to select/enter a value into a dropdown menu using Python Requests, but for some reason it is not working. Here is the HTML code: <select name="hourly_rate" class="default-input" id="hourly_rate"> <o ...