Adjusting the size of a carousel within a modal using Bootstrap

Currently, I am in the process of building my new website and one feature I would like to include is a modal that displays both text and images. The images are stored in a carousel format.

Most aspects of this setup are functioning properly, except for the image sizing issue. In my database, I have images with varying sizes and orientations. When clicking on an image, a modal opens up displaying information about the image along with the image itself. However, not all images fit perfectly within the modal and some end up distorted.

I'm unsure of the best approach to solve this problem. Should I modify the CSS of the modal or the carousel?

My initial thought is to resize the image if it doesn't fit neatly into the modal container.

                 
<div class="modal fade" id="modal-<?php echo $id; ?>" tabindex="-1" role="dialog"
aria-labelledby="exampleModalLabel"
aria-hidden="true">

    <div class="modal-dialog modal-xl" role="document">
        <div class="modal-content">
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-md-4">
                            <h5 class="modal-title" id="modalLabel"><?php echo $title; ?></h5>
                            <div class="mt-5">
                                <p><?php echo $technique; ?></p>
                                <p><?php echo $size; ?></p>
                                <p><?php echo $date; ?> </p>
                                <p><?php echo $location; ?></p>
                            </div>
                        </div>
                        <div class="col-md-8">
                            <div class="carousel slide" id="imageCarousel-<?php echo $id ?>"
                                 data-ride="carousel">
                                <ol class="carousel-indicators">
                                    <li data-slide-to="1"
                                        data-target="#imageCarousel-<?php echo $id ?>"
                                        class="active"></li>
                                </ol>

                                <div class="carousel-inner">
                                    <div class="carousel-item active">
                                        <img class="d-block w-100"
                                             src="<?php echo $url ?>"
                                             alt="image slide">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close
                </button>
                <button type="button" class="btn btn-primary">Inquire</button>
            </div>
        </div>
    </div>
</div>

The screenshot below shows an example where the picture should be stretched more vertically: https://i.sstatic.net/GCUG0.jpg

Answer №1

For an improved appearance, consider incorporating the CSS style below into the carousel slide class: vertical-align: middle;

Answer №2

After doing some research, I stumbled upon a helpful tip in a different forum that solved my issue:

.full-width {
    width: 100% !important;
    height: 100%;
}

Simply adding this snippet to my CSS file did the trick!

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 input data from the MySQL database requires two page refreshes in order to be retrieved

Every time I input new values into the form fields and submit them, the page needs to be reloaded twice to display the updated values. For example, consider the $balance_2 in the 7th line. This line calculates the sum of all row values and updates the Bal ...

Retrieving data from relational databases based on specific conditions in Django

I've been encountering some challenges with rendering a particular view ('myprojects') that displays the projects associated with a user from the 'uProjects' model. To address this, I created an object_list to filter 'uProject ...

Unchecked checkbox displays as checked in UI

I am facing an issue with checking checkboxes using JavaScript. Even though the checkbox appears to be checked in the program, it does not reflect the updates on the user interface. If anyone has a solution for this, please share. <!DOCTYPE html> ...

Troubleshooting resizing images in React using Material UI's useStyles

When attempting to resize an image using React, I am encountering a problem where adjusting the height and width of the tag with useStyles does not reduce the size of the image but instead moves it around on the page. Here is the code snippet: import { ma ...

Textbox textchange event triggers Javascript function when Checked=True

$('.LblQTY').on('input', function () { var currentRow = $(this).closest('tr'); var rate = parseFloat(currentRow.find('.LblRate').text()); var quantity = parseFloat($(this).val() == '' ? '0& ...

Capture information from an HTML5 form and securely store it in a MySQL database

I have a simple web form that includes a "date" type input field. I want to retrieve the date entered by the user and store it in my MySQL database, which has a DATE type column. I am looking for some PHP/JS magic to facilitate the communication between t ...

Click on the event to save the document and print the HTML page

Is there a way to create an onclick event that saves the current HTML page as a document and then prints it? <html> <body> <div class="reportformat"> <div class="format1"> <table> <tr ...

Vertically and horizontally align an SVG within 2 divs without modifying the parent div of the SVG

Is there a way to center an SVG both vertically and horizontally inside a div? The issue is that the width and height of the SVG are determined using the vx-responsive library, resulting in the following DOM structure: https://i.sstatic.net/3p2wc.png Edi ...

Endless Google Locations Instances

My database entries are being displayed in a table using input fields. I want the Location field for each entry to be automatically completed using Google's API. HTML: <input name="edit_airplane[1][location]" type="text" class="airplane_location" ...

CSS image buttons are causing active_link_to list items to disappear when they become inactive

I'm struggling to get the nth css button/list elements to display correctly using active_link_to. The first css button appears without any problems and is active, but when I try to add new buttons to the list, they seem to disappear. HTML <li cla ...

Adjusting the height of an element in AngularJS based on its width dynamically

I am working on a table that is generated using ng-repeat, and I want to ensure that each td in the tbody is square. Since all the tds have an equal width, I only need to adjust the first one. However, the size of the table and td will change when the wind ...

Saving Selected Radio button values into Jquery Array

In my HTML table, there are multiple rows with radio buttons representing the sexes in the 0th position of <td>. I am trying to store the values of sex (either 1 or 0) in an array. Below is a snippet for a table with 3 rows. HTML Code: <table> ...

Can you provide me with instructions on how to create a toggle effect for a button using vanilla JavaScript?

Looking for guidance on creating a toggle effect with a button that switches between 2 images. I've managed to get it working with event listeners on btn2 and btn3, but can't seem to implement the 'toggle' effect on btn1. Any insights o ...

Optimizing CSS for Landscape Letter Print Alignment

When attempting to print in letter size and landscape orientation, the two divs fail to align properly. However, when using "@size a4 landscape" for printing, the alignment issue is resolved. What could be missing from my print CSS that would allow them to ...

Apply CSS styles from a text area using v-html

I am currently working on developing a unique WYSIWYG application where users have the ability to write CSS in a textarea field and view its direct impact on the HTML content displayed on the page. As I was experimenting with different approaches, I attemp ...

The main page wrapper will be centered on all devices except for tablets, where it will appear

I have set up a main container, #main, for my page content with a central position. It is positioned absolutely to create some space above the container. Centering is achieved using negative margins and left:50% instead of margin:auto. However, the issue a ...

Creating a responsive grid division

.subcategory-main-wrapper { display: grid; grid-template-columns: repeat(4, max-content); position: absolute; width: 100%; column-gap: 4%; justify-content: center; height: 360px; @media @tabletScreens { height: 280px; } @media @ ...

Close dynamic overlay modal when client-side validation fails during submission

When a user clicks on the "Apply" button after opening a "confirm" modal, client-side validation checks all fields. However, in case of failure, the modal does not close and I am struggling to find a solution. I attempted to use an event handler on the su ...

Add a blur effect to a specific region of an SVG image

I have a complex, dynamic SVG image created using jQuery SVG. I want to create a "popup" area that appears on top of all SVG elements in the canvas. To achieve a modern translucent iOS7 style, I would like to add a blur filter to everything beneath the pop ...

curved edges and accentuate the chosen one

I've been working on an angularJS application that includes a webpage with multiple tabs created using angularJS. Check out this example of the working tabs: http://plnkr.co/edit/jHsdUtw6IttYQ24A7SG1?p=preview My goal is to display all the tabs with ...