Ways to position every additional post alongside one another?

I'm currently working on my blog and I want new posts to be displayed next to each other, rather than stacked on top of one another. I have these cards set up, but they keep stacking underneath each other. If you need more of my code to help me out, please let me know.

Any assistance would be greatly appreciated!

I'd like it to look something like this

post.html

{% extends "online_shop/base.html" %}
{% load static %}
{% block content %}
    {% for post in posts %}

    <head>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
  
        <body>
          
           <div style="margin-top: 35px;"></div>

            <div class="card-deck" style="max-width: 300px;">
              <div class="card row">
                <img class="card-img-top" src="{% static 'online_shop/unicorn-cake-14.jpg'%}" alt="Card image cap" width="300" height="310">
                <div class="card-body">
                  <h2><a class="article-title" href="#">{{ post.title }}</a></h2>
                  <p class="card-text">{{ post.content }}</p>
                  {{ post.content|truncatewords_html:15 }}
                </div>
                <div class="card-footer">
                  <small class="text-muted"><a href="#">{{ post.author }}</a></small>
                  <small class="text-muted" style="margin-left: 5px;">{{ post.date_posted|date:"F d, Y" }}</small>
                </div>
              </div>
            </div>
        </body>
    {% endfor %}
{% endblock content %}

Answer №1

I encourage you to review the code and execute it in full-page view. I've created something similar to what you're looking for on your blog page.

To achieve responsiveness and improve user interactivity, I utilized display: flex.

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap'); 
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
  }

body{
    background: rgb(235, 235, 235);
    
  }

.flex-box {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.card-1{
    position: relative;
    width: 480px;
    height: 720px;
    background: #eaf5f0;
    border-radius: 5px;
    box-shadow: 0 35px 80px rgba(0,0,0,0.15);
    transition: 0.5s;
    margin: 25px;
  }

.card-1 .heading-1{
    margin: 10px;

}
.card-1 .content-1{
    position: relative;
    height: 100%;
    width: 480px;
    padding-left: 10px;

}

.card-1 .extra-1{
    position: relative;
    padding : 10px;
    color: black;
    font-weight: 700;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="q3.css" />
    <title>Blog</title>
  </head>
  <body>
    <div class="flex-box">
        <div class="card-1">
            <div class="image-1">
                <img src="https://www.storbeck-isolierungen.de/images/photos/480.png">
            </div>

            <div class="detail-1">
                <h2 class="heading-1">Lorem ipsum </h2>

                <p class="content-1">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
                
                <p class="extra-1"> DATE : dd/mm/yyyy</p>

            </div>
        </div>

        <div class="card-1">
            <div class="image-1">
                <img src="https://www.storbeck-isolierungen.de/images/photos/480.png">
            </div>

            <div class="detail-1">
                <h2 class="heading-1">Lorem ipsum </h2>

                <p class="content-1">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
                
                <p class="extra-1"> DATE : dd/mm/yyyy</p>

            </div>
        </div>

        <div class="card-1">
            <div class="image-1">
                <img src="https://www.storbeck-isolierungen.de/images/photos/480.png">
            </div>

            <div class="detail-1">
                <h2 class="heading-1">Lorem ipsum </h2>

                <p class="content-1">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
                
                <p class="extra-1"> DATE : dd/mm/yyyy</p>

            </div>
        </div>
        
    </div>
    <script src="script.js"></script>
  </body>
</html>

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

Personalizing User Profile in Django

I have encountered an issue where I am unable to save new fields in the user profile on the frontend, even though it is functioning correctly on the admin side. There are no error messages displayed, it just fails to save the data. Specifically, I have ad ...

MySQL automatically inserts a null record if no value is provided

Currently, I am working on a project that involves inserting, viewing, and deleting records. Although everything functions smoothly, an issue persists where a null record is automatically added for some reason. The deletion feature works perfectly for othe ...

A guide on adding specific rows together in a list

I'm working with a grid that contains various items and I want to calculate the total of the val_itemservico column only for the selected rows, not all of them. How can I achieve this functionality? When the user clicks on the "Calculate" button, I n ...

Changing the content of a PHP div with an Ajax callback inside another Ajax callback?

In the index.php file, there is a script that triggers an ajax call when a header element is clicked. This call sends a $selection variable to ajax.php, which then replaces #div1 with the received HTML data. <script> $(document).ready(function(){ ...

Error message: The desired element is not found in the cache when selecting a radio button with mechanize::phantomjs

Currently, I am working on automating a webpage that contains numerous JavaScript functions using Perl. I have been successful in utilizing the headless mechanize::phantomjs toolkit thus far. However, I have encountered what seems to be a minor issue that ...

A step-by-step guide on incorporating RAW css into your Jekyll website

I am experiencing an issue with loading a CSS file on my website. <link rel="stylesheet" href="/assets/css/my_file.css"> This file is located at _assets/css/my_file.css. However, when I try to load the page, the CSS file does no ...

The issue with jQuery trigger not passing the value of a radio button has been

I have implemented a radio button (Yes, No) and an input text box on my form. If the user selects 'No', the input field is disabled and jQuery triggers a change event for AJAX form submission. $('#form-id').change(function(){ .... }); ...

Bootstrap4: What could be causing the adjacent row cell to remain left-justified instead of being centered as intended with mx-auto?

I've been working on creating a responsive header using Bootstrap4. The main goal is to have the logo displayed as left-justified text and the menu items as right-justified when the viewport is large, then transition to both being centered in a "small ...

Counting backwards in a Django template using the <ol> tag

I am looking to create a unique template that is paginated, meaning not all list items are displayed on the same page utilizes the -tag for numbering as it is the most semantic way to order the list can be reversed or not based on user preference feature ...

What steps do I need to take to ensure that my AJAX button press request functions properly within my Django setup?

Is there a way to utilize a JavaScript string variable in a Python function and then return it back to a JavaScript variable efficiently? Perhaps using Json/ajax can help with this? To start, there is an HTML element where a string is stored: <h2 id=&q ...

Can you explain the steps to implement this feature in a modal window using jQuery?

My HTML list contains a bunch of li elements. ul li img .det li I am looking to create a modal popup that appears when I click on something. I want this modal popup to have previous and next buttons, preferably implemented using jQuery. I have alr ...

PHP Exception with dual inputs

I am currently exploring the best approach for capturing messages in my PHP code but I'm unsure if it's even possible. Within my simple PHP structure, I am using try and catch blocks like this: if (!$this->issetAndNotEmpty($id)) ...

Will HTML eventually include a syntax for image spriting?

My knowledge of the latest CSS updates is a bit outdated, so I thought it was worth inquiring; The <img> tag is typically written as <img src="/url.png" />, with auto or specified height and width. While I appreciate CSS sprites for their fast ...

Make sure that when a user clicks on the back button in their web browser, it

Designing a file selection menu where users can choose a file and view it in a text area on a new page, allowing for text editing and saving with a click of a button. Users should be able to return to the file selection menu by simply clicking the browser ...

What is the best way to use JavaScript to conceal all div elements?

Can someone please provide a JavaScript solution to hide all divs on a web page without using jQuery? I am looking for a method that does not involve using the arrays that are associated with document.getElementByTag. If this is not possible, could you p ...

Compel the content element to scroll forcefully

I've scoured the vast expanse of the internet, but my search has been fruitless. Here lies my dilemma. I want my <main> element to have a scrollbar with overflow-y:scroll. No scrollbar on the body, just on the main element. For a visual repr ...

Encountering a webdriver error when using Selenium with Psycopg2 and Postgres on Mac OSX Mavericks

In my Django app, I utilize Postgres. The PostgreSQL software was initially installed using the "one-click" installer provided by EnterpriseDB. To enable Postgres functionality, I executed the command export $DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.3/lib ...

How can you deselect nested checkboxes while maintaining the currently selected checkbox using jQuery?

In my WordPress site, I have a structure of nested checkboxes within ul and li elements. Here is the HTML code: <ul class="woof_list woof_list_checkbox"> <li> <label class="woof_checkbox_label" for="woof_uncheck">Parent Categor ...

Guide to using AJAX to send a select tag value to a PHP script on the current page

Issue I am facing a problem where I need to utilize the select tag in order to choose a value and then send that value via an ajax call to a PHP script embedded within the same page. In my code, I have implemented the select tag and upon selecting a valu ...

When using @RestController in the following code, the HTML file is not being returned properly in the REST API. Instead, only the file name such as 'index' is displayed on the screen

Having trouble getting the HTML file to return in the Rest API. Only returning the file name like 'index' when using @RestController, but works fine with @Controller. I am working on a Spring Boot REST application and utilizing index.html with Bo ...