Creating a layout with 2 rows and 5 columns in Bootstrap 5 may not perfectly fit a 100% width and 100% height

Can someone assist in adjusting this Bootstrap 5 code to perfectly fill the entire screen of all 16:9 devices (mobile and desktop/1080p/2160p using Chrome browser) with 100% width and height? The goal is to eliminate horizontal and vertical scrolling. Despite reviewing over 100 examples and tutorials, a suitable solution has not been found yet. All images maintain a 16:9 aspect ratio.

Even on a 1920p width landscape mobile screen, there may still be a slight need to scroll about 5% to the right and down. However, it's mostly just empty space without any critical content.

Preferred layout: the first row occupies approximately 40% of the total height, while the second row takes up the remaining 60% to accommodate 5 columns of equal size. The image in the first column should utilize the entire 40% height allocated to that row.

Desired layout:

------------------------------------------------------
-                                                    -
-          big-img-big-img                           -
-          big-img-big-img    have a nice day        -
-          big-img-big-img                           -
-          big-img-big-img                           -
-          big-img-big-img                           -
-          big-img-big-img                           -
------------------------------------------------------
-                                                    -
-   img-img   img-img   img-img   img-img   img-img  -
-   img-img   img-img   img-img   img-img   img-img  -
-   img-img   img-img   img-img   img-img   img-img  -
-    text      text      text      text      text    -
-                                                    -
------------------------------------------------------

The provided source code:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>a</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</head>

<body>
<div class="d-flex flex-column vw-100 vh-100">
  <div class="row justify-content-center row-cols-1">
    <div class="card mb-4 justify-content-center" style="max-width: 1920px;">
      <div class="row g-0">
        <div class="col-md-4"> <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/16x9_by_Pengo.svg/128...
        ...
      </div>
    </div>
  </div>
  <div class="row d-flex justify-content-center row-cols-5">
    <div class="col-lg-2 col-md-2 col-sm-2">
      <div class="card mb-3" style="max-width: 1920px;">
        <div class="row g-0">
          <div class="col-md-12"> <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/16x9_by_Pengo.svg/128...
        ...
      </div>
    ...
</body>
</html>

Ideally, achieving a setup where the 5 columns occupy 100% width without any horizontal scrolling would greatly improve the user experience. Any assistance in accomplishing this seamless display without the need for additional scrolling would be highly appreciated. While the current design is responsive, there may be room for further refinement. Thank you!

Answer №1

When utilizing bootstrap, consider the following key points:

  • Columns in a row will maintain uniform height if images have the same aspect ratio.
  • A row can hold a maximum of 12 grid items.

To achieve a layout split of 40% and 60%, you can opt for either col-5 and col-7 or col-4 and col-8 for the first row.

A simpler structure for the second row involves having a single row with multiple columns of either col-2 or just col.

See below for an example that demonstrates these principles:

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2f4d40405b5c5b5d4e5f6f1a011f011d">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" />

<div class="row">

  <div class="col-5">
    <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/16x9_by_Pengo.svg/1280px-16x9_by_Pengo.svg.png" class="img-fluid" />
  </div>

  <div class="col-7">
    Place content here.
  </div>

</div>

<div class="row">

  <div class="col-2">
    <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/16x9_by_Pengo.svg/1280px-16x9_by_Pengo.svg.png" class="img-fluid" />
    <p>Some text here.</p>
  </div>

  <div class="col-2">
    <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/16x9_by_Pengo.svg/1280px-16x9_by_Pengo.svg.png" class="img-fluid" />
    <p>Some text here.</p>
  </div>

  <div class="col-2">
    <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/16x9_by_Pengo.svg/1280px-16x9_by_Pengo.svg.png" class="img-fluid" />
    <p>Some text here.</p>
  </div>

  <div class="col-2">
    <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/16x9_by_Pengo.svg/1280px-16x9_by_Pengo.svg.png" class="img-fluid" />
    <p>Some text here.</p>
  </div>

  <div class="col-2">
    <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/16x9_by_Pengo.svg/1280px-16x9_by_Pengo.svg.png" class="img-fluid" />
    <p>Some text here.</p>
  </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

Using images in R Shiny with htmlTemplate: A step-by-step guide

In my current project, I have a file named template.html that I am loading using the code snippet below: https://i.sstatic.net/TipvS.png One issue I'm facing is including an image in this template.html file. Despite having the correct relative path ...

My HTML and CSS design is not displaying correctly on mobile devices

Currently, I am in the process of utilizing a free website template. However, I am facing an issue with adjusting the background image. Is there anyone who can provide some guidance on resolving this particular problem? I would be happy to share the code ...

Encountering XMLHttpRequest errors when trying to make an AJAX POST request

I'm encountering an issue with a modal containing a form for submitting emails. Despite setting up the ajax post as usual, the submission is failing consistently. The console displays the following two errors: Setting XMLHttpRequest.withCredent ...

Additional <li> elements are created in Internet Explorer versions 8 and 9

Currently in the process of setting up a new website/landing page. Upon heading to the right column at the bottom (where the pictures are located), you will notice <li> elements containing pictures within containers. The only issue that arises is whe ...

Glistening R resize plotOutput

Attempting to resize a plotOutput using Shiny R. The plot in question can be viewed https://i.sstatic.net/fgzag.png This is the code snippet: #In ui: fluidRow( column(width = 12, h4("Diagrama Persistencia"), plotOutput("Dia ...

Creating a responsive design that adapts to various image sizes

In my API response, I am receiving images of various sizes. To display these images on my HTML page, I have created a table containing 4 images. To ensure responsiveness, I have set the width of the table to 100%, each row (tr) to 100%, each cell (td) to 2 ...

Numerous textareas fail to function properly according to JQuery's standards

Need help with resizing multiple textarea elements dynamically as the user types in them (on the Y-axis). Currently, I have code that successfully resizes a single textarea, but it does not work when there are multiple textareas on the page. Here is the c ...

The table will remain empty for eternity as the page is being loaded using ngRoute

Currently, I am utilising Angular routers. app.config(function($routeProvider) { $routeProvider .when('/comment/list', { templateUrl: 'commentList.htm', controller: 'mainController' }) }); ...

Automated Heading Organization with jQuery: Easy Numbering from H1 to H6

After going through various related posts without finding a solution for IE, I am reaching out for help with a jQuery-based approach to address this issue: My content includes nested hierarchical Headings in the following structure: <h1> heading 1& ...

The dynamic JavaScript in Bootstrap 4 seems to be malfunctioning, despite working perfectly in Bootstrap 3

I am currently implementing a dynamic modal feature using the code snippet below: // Show Ajax modal with content $(document).on('click', '[data-modal]', function (event) { event.preventDefault(); $.get($(this).data('moda ...

"Enhancing User Interaction with jQuery Hover State Dropdown Menus

Here's my issue: I've created a drop-down menu and I want the text color to change when hovering over the menu. Additionally, I'd like the hover state to remain active when hovering over the submenu. Currently, I'm using this code: $( ...

Height of VUE Carousel 3D Slider dimension

I recently integrated the VUE Carousel 3D Slider on my website, but I'm facing an issue with controlling the height of the slides. There seems to be excessive space below the slider because the slides are unnecessarily tall. I attempted to adjust the ...

Embeddable video player failing to adjust size properly within parent div

I've been tackling the challenge of making iframes responsive within a div element, but I've hit a roadblock. While there are plenty of solutions available online, none seem to work seamlessly when dealing with YouTube video embeds. Currently, m ...

Activate the button solely when the text field has been populated without any spaces

Searching for a solution to my query, but all the suggestions I've encountered don't consider spaces as valid input. In the join function I have, the button should be disabled if the user enters only spaces. A requirement is for actual text inpu ...

How can links in HTML be eliminated if a certain condition is not fulfilled?

If a specific condition is met, I would like to eliminate the "a href" tag. For example, when the term "None" is present, I prefer it not to be linked. html: {% for item in responses %} <tr> <td ...

Navigation bar failing to show all content on Safari web browser

When navigating to this website, http://www.togethermutualinsurance.co.uk, using any browser except for Safari on Windows, the menu displays correctly. However, in Safari, the title of the menus and submenus with images does not display properly. Despite ...

JavaScript error message stating that the setAttribute function is null

As a newcomer to JS, I am currently working on creating a task list webpage that allows users to submit projects and create task lists within each project with designated due dates. In order to generate unique ID tags for projects and tasks, I utilized UU ...

Ways to align text in the middle and shift it downward?

I'm currently attempting to center the bottom navigation bar using the following CSS code: #main-nav { margin-left: auto; margin-right: auto;} Unfortunately, this method is not achieving the desired result. I even tried adding <center></cen ...

- Prefixing with -webkit-transform and overlooking z-index

When using Safari 5.1.7 on Windows, I noticed that some rotated elements are overlapping others: However, when I test it on Firefox, Chrome, and IE, the issue doesn't occur: Is there a solution to prevent this overlap problem specifically on Safari? ...

jQuery does not support CSS pseudo-code

I'm having trouble with my CSS pseudo-code not being recognized by jQuery. Here is the code I'm using: CSS: h1 { background: red; width: 100px; display: inline-block; } h1:after { content:" | "; background:blue; display ...