Ways to create adaptive images using Bootstrap 5

On my website, there are some cards that look great on large and medium screens. However, on small screens, the images appear stretched vertically!

I am using Bootstrap 5 and here is the code snippet:

                        <div class="col-12 mb-4">
                        <div class="card m-auto w-100 h-100 rounded">
                            <div class="row g-0">
                                <div class="col-4 h-100">
                                    <img src="{{ i.image.url }}" class="img-fluid rounded h-100" alt="...">
                                </div>
                                <div class="col-8">
                                    <div class="card-body">
                                        <p class="weblog-post-title card-title" style="font-size: 1.25rem;">{{ i.title }}</p>
                                        <p class="weblog-summery card-text text-muted">{{ post.summery|truncatechars:70 }}</p>
                                        <div class="row mt-2">
                                            <div class="col-6">
                                                <p class="card-text"><small class="text-muted">{{ i.create|date:"SHORT_DATE_FORMAT" }}</small>
                                                </p>
                                            </div>
                                            <div class="col-6 text-start">
                                                <a href="{{ i.get_absolute_url }}"
                                                    class="btn btn-green btn-sm mt-2" style="border-radius: 10px;">see</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

Here is an image showing how it looks on large screens:

https://i.sstatic.net/m9lx6.png

And here is an image showing how it looks on small screens:

https://i.sstatic.net/Eb6Va.png

Answer №1

Utilize Media Queries (sm:, md:, lg:, xl:, xxl:) to ensure images are responsive across different screen sizes.

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

The inefficacy of the JQUERY validation plugin, AJAX, and PHP integration

After diving into learning AJAX for submitting forms, I've encountered a roadblock. The data I submit doesn't seem to reach the PHP file as expected, and I can't figure out why it's failing. Here's my HTML: <div class="col-md- ...

Special Table Spacing

Within my table, I am looking to create spacing between cells without setting padding and/or margin on each individual td. While using the CellSpacing and/or CellPadding properties of the table could be a potential solution, these properties apply space on ...

Troubleshooting: Issues with jQuery's Class selector

Having trouble setting up an alert to trigger when a specific class anchor tag is clicked inside a div. This is what my HTML section looks like... <div id="foo"> <a class='bar' href='#'>Next</a> </div> And h ...

Exploring Rails 6: Enhancing Web Design with CSS Image Display

I've been attempting to update my webpage background with an image through CSS, but I'm struggling to reference one of my Rails 6 images in the process. Despite trying options like asset-url and image-url, I haven't been successful. However, ...

Exploring the power of nested styled components in Material UI is a great way to elevate the styling of your project

Can someone explain how to access a second styled component using '@mui/system' in order to add a hover effect to a parent element that will modify the max-height of its child? Please keep in mind that I am referring to mui's styled compone ...

Navbar collapse not functioning properly on HTML, CSS, and JavaScript

I have developed a CSS code snippet: .nav{ right: 0px; left: 0px; margin-top: 0px; margin-bottom:20px; height: 35px; text-align: center; background-color: red; z-index: 1; } .sticky { background: #000; text-align: center; ...

Stop unwanted scrolling upwards by using jQuery ajax function $.load

I'm currently in the process of creating an ajax chat using jquery and php. Everything seems to be running smoothly except for one issue related to scrolling. Essentially, I've implemented a time-out function that automatically reloads the inner ...

Tips for maintaining variable values when invoking PHP functions

After setting a global variable value in a PHP functions file and successfully using it within one PHP file, I encountered an issue when trying to access the same variable from another PHP file using include("functions.php"). This is the process I followe ...

What is the best way to format a time in a 12-hour clock using JavaScript?

Is it possible to create a timer that performs an action after 12 hours? I want the timer to start at 6am and end at 6pm, lasting for exactly 12 hours. Additionally, I'm interested in converting my current 12-hour clock into a 24-hour format. I am se ...

Converting HTML/Javascript codes for Android Application use in Eclipse: A Step-by-Step Guide

How can I implement this in Java? Here is the HTML: <head> <title>Google Maps JavaScript API v3 Example: Geocoding Simple</title> <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="styles ...

I'm having trouble figuring out the code for the path in the POST request for my basic login form application

I have built a basic login form application in node.js. Although I can successfully display the login form and input login data, my POST request to capture the login data is not functioning correctly. I am encountering a POST http://localhost:3000/client 4 ...

Checking Twitter follower count using Jquery and JSON

Here is a script that counts twitter followers:. However, it seems to be displaying the list of followers twice. I would like some assistance in getting just the follower count stats for the array elements. Thank you! echo "<div id='twitter'& ...

Vuetify: how to disable the color transition for v-icon

My menu includes both icon and text items, with hover color styled using the following CSS: .v-list-item:hover { background: #0091DA; } .v-list-item:hover .v-list-item__title, .v-list-item:hover .v-icon { color: white; } The problem is that the ...

Using a global variable to change the class of the <body> element in AngularJS

I've recently developed an angularJS application. Below is the index.html <html ng-app="MyApp"> <head> <!-- Import CSS files --> </head> <body class="{{bodylayout}}"> <div ng-view></div> < ...

Uncovering the jsPlumb link between a pair of identifiers

Could someone help me understand how to disconnect two HTML elements that are connected? I have the IDs of both elements, but I'm not sure how to locate their connection in the jsPlumb instance. Any tips on finding the connection between two IDs? ...

Choosing an option in react-select causes the page to unexpectedly shift

Encountering a problem with a mobile modal developed using react-select. The selectors are within a div with fixed height and overflow-y: scroll. Upon selecting an option for the 'Choose observer' select, the entire modal briefly jumps down in th ...

The background color of absolute divs fails to extend across the entire screen

Trying to implement a loading screen in my VueJs app using only divs. The issue is that the background color of the divs (loadingScreen) does not cover the entire screen, but only as much as the loader's height. I've attempted adding margin to th ...

Django informing me that the template is not found

Why am I getting a "template does not exist" error in Django? I'm trying to navigate from film_detail.html to film_report.html by clicking on the "report" button... views.py class FilmReport(LoginRequiredMixin, UpdateView): model = Report fi ...

Searching for the name of dynamically generated input fields using jQuery

I have a straightforward form featuring radio buttons <form> <input type="radio" name="radio_1" value="1" />Radio 1 <input type="radio" name="radio_1" value="2" />Radio 2 <input type="radio" name="radio_1" value="3" />Radio 3 </ ...

An issue has been discovered where IE8 is unable to print an image within the :before pseudo

Is there a way to display an icon image before text without using HTML tags like <img> that may interfere with our JavaScript code if the structure of the HTML changes? I came up with the following code which successfully displays the icon on IE8 an ...