Creating a 2x2 image grid using Bootstrap with each image set to have a height and width of

I'm currently facing a challenge in creating a responsive grid of 2x2 images using bootstrap.

My goal is to have the images adjust to either the height or width of the browser. However, I seem to be stuck at this point while working with bootstrap.

Sample Code:

<div class="container">
  <div class="row">
    <div class="col"><img id="Image1" class="img-fluid" src="9e6845.jpg"></div>
    <div class="col"><img id="Image2" class="img-fluid" src="6845.jpg"></div>
    <div class="w-100"></div>
    <div class="col"><img id="Image3" class="img-fluid" src="98d6e6845.jpg"></div>
    <div class="col"><img id="Image4" class="img-fluid" src="9e6845.jpg"></div>
  </div>
</div>

Challenge Encountered:

  • The container has been set to max-width:1140px, resulting in empty space on taller screens.
  • If I set the container's max-width to 100%, the image width extends beyond the visible area of the browser.
  • Should I resort to using jQuery or a similar method to calculate the total height/width and then divide it by 2 to set the image sizes? Or is there a way to achieve this using bootstrap/CSS/HTML?

The standard bootstrap container does not scale to fill the width as desired. https://i.sstatic.net/2oFo3.png When set to 100% width, the images extend outside the viewable area of the browser window. https://i.sstatic.net/48gZx.png

Answer №1

It is important to specify the resolution of your images and ensure they have proper aspect ratios. Be sure to crop them accordingly for best results.

If you need more information on aspect ratios, there are plenty of resources available online. Check out this link for an overview: Aspect ratios

Clear pictures are also greatly appreciated.

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

Tips for ensuring a scrollbar remains at the bottom position

I'm facing an issue with a scroll-bar inside a div element. Initially, the position of the scroll-bar is at the top. However, whenever I add text to the div element, the scroll-bar remains in its initial position and does not automatically move to the ...

Guide to vertically aligning text in an overlay using CSS within Angular 2

I currently have an overlay on my page that displays a spinner (an Angular material component) and accompanying text. This overlay covers the entire page and prevents clicking on elements below it. The spinner is positioned in the center of the page, and ...

Problem with the padding on the right side

I'm currently working on implementing responsive design for a website. My main challenge right now is ensuring that the navigation menu stretches to the total width without any padding issues on the last element ("Equipo"). I want this element to reac ...

The origin of the image is specified within the HTML document

I recently encountered an issue while trying to include images in my HTML file. When I used a local file path like background-image: url('file:///C:/Users/faycel/Desktop/site%20guide/paris.jpg'), the image displayed correctly. However, when I tri ...

How to position an image on top of each printed page using HTML/CSS (SCSS)

I've created a simple and small webpage that looks like this: https://i.sstatic.net/R7Ajz.png Everything is perfect in the browser, with all the styles (margin, padding, etc.) just as I want it. However, my issue lies in the print view of the page. ...

Mouse position-based scrolling that preserves click events in the forefront while scrolling

Within a larger div, I have a very wide inner div that scrolls left and right based on the position of the mouse. I found the code for this from an answer at There are two transparent divs above everything else, which capture the mouse position to determ ...

Turn off all the styles associated with a specific CSS selector

Looking for a solution to override CSS rules for the .lp-caption selector? .lp-caption { -moz-border-bottom-colors: none; -moz-border-left-colors: none; -moz-border-right-colors: none; -moz-border-top-colors: none; backgr ...

locate the following div using an accordion view

Progress: https://jsfiddle.net/zigzag/jstuq9ok/4/ There are various methods to achieve this, but one approach is by using a CSS class called sub to hide a 'nested' div and then using jQuery to toggle the Glyphicon while displaying the 'nest ...

Click here to navigate to the anchor and expand the accordion

Is there a way to open an accordion panel using an external anchor link? I attempted to use an anchor link, but it only loads the page without opening the panel. My goal is to have the page load, scroll to the panel, and then open the accordion when the ...

Creating a half-page Bootstrap Carousel: Steps and Tips

Is there a way to make this Bootstrap 3 carousel half-page? I'm struggling to figure out what adjustments need to be made in order to achieve that. It displays well in a small window, but once I expand it to full screen, the carousel takes over the en ...

Load Angular component on demand with necessary dependencies

Searching for an elegant solution (without resorting to private APIs) to create a widget-style dashboard. The goal is to dynamically load components based on user role. Is there a way to import a component and its dependencies included in the component&ap ...

Attach the footer to the bottom of the screen only if the main page text is limited in length

How can I ensure that my footer sticks to the bottom of the screen only when there is minimal content on the page? When there is a lot of content, I'd like the footer to appear after the content rather than being pinned at the bottom, especially since ...

Using the JQuery Library, you can implement two submit buttons that either open in a new tab or submit

I am facing a situation where I have a FORM containing two submit buttons. My requirement is that when the first button is clicked, the form should submit on the same tab. On the other hand, if the second button is clicked, it should proceed to open a new ...

What could be the reason why the links within my drop-down menu are not directing me to other pages?

As I work on developing a new website, I have encountered an issue with the content inside my dropdown button not being engaging enough. Specifically, I have a link within a dropdown button located in the footer (visible on mobile), but this link does not ...

HTML Preview is not rendering properly

https://i.sstatic.net/dqwR8.png I'm having an issue where the HTML I received is displaying without a header and footer like in the image provided. Can anyone help me understand why this is happening? I will attach the code below: ...

Is there a way to place labels or paragraphs directly on top of objects?

How can I center these labels on top of the items in my layout? Placing the <ion-label> has positioned the labels to the left of the items instead of centered. Is there a way to achieve top center alignment without affecting the round shape of the ch ...

List within a list that is only displayed if a specific condition is

Looking for help with CSS styling to make an embedded list display as a contiguous list in the final output. Here's the scenario: <ol> <li>Coffee <! -- embedded unordered or ordered list - begin --> <ul> <li>Ap ...

problem specifically occurring on tablets with fixed positioning

Have you checked out the site I'm referring to here? An unusual issue seems to be occurring specifically on tablets. We implemented the scroll to fixed jQuery plugin to fix the position of the sidebar after scrolling, which works perfectly on all de ...

The Safari 7.1+ browser seems to be having trouble with the spotlight effect

Why is the CodePen not functioning properly in Safari? Despite working well in Chrome and Firefox, it completely fails to work in Safari 7.1+. Can anyone provide some insights? http://codepen.io/cchambers/pen/Dyldj $(document).on("mousemove", function( ...

Creating Interactive Functions with JavaScript MouseMove Events

Currently, I'm undertaking a class assignment that requires an interactive element. I've decided to utilize the mousemove syntax to modify the color and size of the lines within my project. These lines are created within a div in my HTML file usi ...