Creating visually appealing forms with Bootstrap 4 in Django Template for loop

I am attempting to display my formdata (including text and an image) on the screen using bootstrap in a way that arranges the blocks of data (text + image) next to each other instead of one below the other. I have tried adjusting column sizes, but have been unsuccessful so far. Currently, all containers are stacked vertically on a large screen. The layout looks good on a small screen, but does not transition correctly to utilize the remaining columns on a larger screen

<div class="container-fluid">

<h1 class="my-4 text-center text-lg-left">Thumbnail Gallery</h1>

    {% block content %}
    {% for contexts in context %}
    <div class="col-lg-auto col-lg-auto col-6-auto">
    <h2>Title: {{ contexts.title }}</h2>
    <p>Category: {{ contexts.category }}</p></div>
    <p>Description: {{ contexts.description }}</p>
    <p>Price: {{ contexts.price }}</p>
    <p>Created: {{ contexts.created }}</p>
    <img class="img-fluid img-thumbnail" src="{{contexts.document.url}}" width="20%" height="20%"/>
    </div>
    {% endfor %}
</div>

Answer №1

One of the strong points of Bootstrap lies in its grid classes. Explore them here

If you're unsure about the layout you need, this snippet might point you in the right direction.

<div class="row col-6">
    <div class="col-6 left">
        <h2>Title: {{ contexts.title }}</h2>
        <p>Category: {{ contexts.category }}</p></div>
        <p>Description: {{ contexts.description }}</p>
        <p>Price: {{ contexts.price }}</p>
        <p>Created: {{ contexts.created }}</p>
    </div>
    <div class="col-6 right">
        <img class="img-fluid img-thumbnail" src="{{contexts.document.url}}"/>
    </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

Finding your site's First Contentful Paint (FCP) can be done by analyzing the

After doing some research on Google insights, I came across information about FCP. However, I'm still unsure about how to determine my site's FCP and other relevant metrics. If anyone could provide me with more information or share detailed link ...

Eliminate the option to display/hide password icon on Safari

Is there a method to eliminate the show/hide icon in Safari that pops up when entering symbols into an input field with type "password"? I was able to achieve this in IE/Edge by incorporating the following CSS rule: input[type=password]::-ms-reveal, input ...

Challenges with navbar and CSS alignment in Internet Explorer

Looking for some assistance with a HTML/CSS issue... I've created a new menu using the following CSS and code, but I'm encountering a problem with extra space between lines of text within the menu (specifically with the 'big' and &apos ...

Cannot Display CSS Background Image Locally

Apologies for the simple inquiry, but I am facing an issue with displaying my background image using background-image:url() in the CSS. Strangely, it does not work with this method, but when I use content:url(); it works just fine. Interestingly, backgrou ...

What is the solution for getting `overflow-x` to function in place of `overflow-y`?

I have a main container with several sub-containers inside. When the main container's width exceeds its limit, I want to display a horizontal scroll bar. Instead of using the 'display: inline-block' property because it creates unwanted whit ...

Exploring the contrast between window and document within jQuery

I'm curious about the distinction between document and window in jQuery. These two are commonly utilized, but I haven't quite grasped their differences. ...

Creating a multiline textarea with ellipsis using ReactJS

Looking to create a component with a multiline textfield that displays ellipsis (...) for text overflow beyond 2 lines. How can I achieve this through CSS only without modifying the actual stored text? Utilizing the React component found at: link Appreci ...

Having trouble updating Django forms.py with the latest values from the database

models.py class Test(models.Model): name = models.CharField(max_length=256) slug_name = models.CharField(max_length=256) template = models.BooleanField("Is Template",default=False) @staticmethod def template_as_tuple(): return ...

Adjust the background color of a non-selected Material-UI checkbox

Currently, I am working with a combination of React-Redux and Material-UI to style my project. Within this setup, I have a checkbox component that is placed on a toolbar with a blue background color (#295ED9). So far, I have successfully altered the color ...

Customizing the CSS shadow for a specific ionic select text color, while ensuring that other ion select instances remain unaffected

I'm encountering an issue while attempting to customize the text color inside an ion select element based on the option selected. Unfortunately, when I make changes to the shadow part in one component, it affects other components as well. I want to ap ...

Ways to identify when a person has scrolled a specific distance

Is it possible to modify the appearance of my top navigation bar once the page has been scrolled a specific number of pixels? I assume this requires some sort of listener to track the amount of scrolling. I came across element.scrollTop, but it doesn' ...

Is there a way to prevent my Header links from wrapping during window size testing?

https://i.stack.imgur.com/YTc3F.png The image above showcases my standard header layout, while the one below illustrates what occurs as I resize the window. https://i.stack.imgur.com/re44T.png Is there a specific CSS solution to prevent the Text navLink ...

Why does the "margin" CSS style fail to function properly in FlowPanel within GWT?

I'm currently working with Gwt and have encountered a problem with styling buttons. Let's take a look at the following code snippet: .marginRight{ margin-right: 10px; } FlowPanel myFP=new FlowPanel(); Button myButton=new Button("Button"); Butt ...

Building relationships in Django admin using linked lists for foreign keys

In my database schema, I have interconnected foreign key relationships structured like this: class Continent(models.Model): continent = models.CharField(max_length=30) class Country(models.Model): country = models.CharField(max_length=30) con ...

Strategies for aligning the initial lines of text vertically within a table cell

I am faced with a unique challenge involving a table where the first cell contains the word "name" and the second cell contains some text. Sometimes, this text may include embedded images. The issue arises when an image appears on the first line of the tex ...

Utilizing CSS3 to implement multiple backgrounds across various selectors

My goal is to set backgrounds in two different CSS classes, ideally utilizing CSS3's multiple background feature. I aim to achieve this with minimal markup and ensure it is universally applicable. For example: CSS .button { display: block; } . ...

Using `req.body` to retrieve form data in express.js is not permitted

I have a form on my website that collects user data using input and selection fields. I'm looking to use an AJAX call triggered by the submit button's handler to save this data on the server. Below is an outline of the code: Client side: xhr.o ...

Reverting Database Changes in Django Based on Certain Conditions

When a certain condition is met, I need to undo database changes, but until that condition is reached, the changes should be visible to other users. @transaction.atomic def populate_db(input): Object = Table.objects.select_for_update().get(attributeX=in ...

Tips for utilizing flexbox to position a button to the right of an InputSelect

Struggling to position a button next to a dropdown? No matter what I attempt, the button keeps ending up above the dropdown. Ideally, I'd like it to appear alongside 'Select Organisation' as shown in the image below: https://i.sstatic.net/w ...

Steps for Implementing the 'IN' Constraint on Django Model Fields

I am looking to restrict one of the fields in my model to only accept specific values, such as 'a' and 'b'. In SQL, this can be done using the 'IN' constraint. How can I achieve the same functionality using Django model class ...