Bootstrap class="h-100" functioning in Firefox but encountering issues in Chrome

I'm currently working on a project that involves integrating Bootstrap and leaflet for a web mapping application. I've encountered an issue where the map is not displaying properly across all browsers. Specifically, while the map successfully covers the entire height of the main container in Firefox, it fails to do so in Chrome or Safari.

To provide some context, I've structured my HTML with a <body> element set to min-height: 100vh. Within the body, there's a <main> tag styled with flex: 1 0 auto, ensuring it fills the space between the header (<nav>) and footer elements.

Within the <main> tag, I have a

<div class="container-fluid h-100">
which I expect to inherit the height of the <main> itself. Inside this container, there's a
<div id="map" class="h-100">
meant to take up the full height of its parent container.

This setup functions correctly in Firefox but not in Chrome or Safari. You can see the difference here - Firefox displays the map within a container with correct height, whereas Chrome and Safari render the container with zero height and no visible map.

I've ruled out the common issue of % based heights caused by parent elements lacking height. Even in Chrome, the <main> element has been assigned a definite height as evidenced here: <main> with height.

I suspect this discrepancy could be related to the flex property applied to the <main> tag, leading to different height evaluations in various browsers.

For reference, below is the complete HTML structure:

<!DOCTYPE html>
<html lang="en">
  <head>
  </head>

  <body class="bg-dark">
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
      <a class="navbar-brand" href="/"></a>
      <button class="navbar-toggler navbar-dark border-0" type="button" data-toggle="collapse" data-target="#nav-content" aria-controls="nav-content" aria-expanded="false" aria-label="Toggle navigation menu">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse justify-content-end" id="nav-content">
        <ul class="navbar-nav align-items-center">
          <li class="nav-item ">
          </li>
          <li class="nav-item ">
          </li>
          <li class="nav-item">
          </li>
          <li class="nav-item">
          </li>
          <li class="nav-item ">
          </li>
        </ul>
      </div>
    </nav>

    <main>
      <div class="container-fluid h-100">
        <div id="map" class="h-100"></div>
      </div>
    </main>

    <footer>
    </footer>
  </body>
</html>

Additionally, relevant CSS styles are included below:

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1 0 auto;
}

If anyone has insights or suggestions to resolve this issue, I'd greatly appreciate your assistance.

Answer №1

Before conducting extensive experimentation, the question was posed. The problem was resolved by inserting the following CSS:

html, body {
  height: 100%;
}

The reason behind its effectiveness eludes me, therefore I welcome a more comprehensive explanation from anyone willing to provide it.

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

Modifying a string in PHP before inserting it into a database

I am looking to save a method for performing a specific task in a database field. However, I want to store this method as a string including HTML tags. For instance, the following list should be included: <ul> <li>List item</li> <li&g ...

The VBA script I use to extract data from the web is causing my laptop to run sluggishly

Today marks my first venture into creating a VBA Excel program for scraping data from a website. Initially, I attempted a simple program to scrape a single value and display it in cells(1,1). Despite encountering numerous failures and multiple warnings fro ...

Utilizing SCSS Interpolation within a mixin invocation

My goal is to incorporate a simple interpolation into a mixin call: $shapes: "square", "square-green", "circle"; $platforms: "facebook", "twitter", "linkedin", "gplus", "feed"; @each $shape in $shapes { @include sprite-#{$shape}; @each $platform ...

Unique style for custom vue multiselect component

I have implemented a Vue Multiselect component, but I am struggling to fully customize it with CSS styles. I have applied some CSS styles, but I am unable to achieve all the customization I want. Specifically, I want to modify the option height, select box ...

Is there a way to modify the space bar and enter key functionality exclusively for the third button, rather than applying it to all buttons?

https://jsfiddle.net/ffkwgddL/ In the code, I have three buttons named first-button, second-button, and third-button. If the first-button (introduction) is clicked and then the space bar is pressed, it functions as if the first button was clicked again. H ...

Guide to positioning a bootstrap navbar toggle button to the left or right of the logo

My React app includes a bootstrap navbar with the following code - <nav className="navbar navbar-default navbar-expand-sm navbar-light bg-light"> <div className="container-fluid"> <div className="navba ...

Track when a user modifies a <select> dropdown list generated using the Jquery method ".html()"

Is it possible to detect a change in the value of a select list when that select list has been added using either the .html(htmlString) or .append(content[,content]) jQuery function? HTML CODE: <ul class="htmlClass"> <!-- Populated via JS --& ...

Are you curious about how jQuery can be used to group buttons together?

In my ASP.NET MVC application, I incorporate JQUERY to enhance the user experience. I am curious if there is a way to group buttons together, not radio buttons but regular buttons. Can I have buttonA + buttonB + buttonC grouped together with some space i ...

What could be causing my div elements to not appear on the page?

Hey there, this is my debut post here so bear with me on the formatting. I'm currently working on a project and encountering some hurdles with my divs. Even though I've left space for them, I just can't seem to get my divs (or cards) to disp ...

PHP can seamlessly integrate with HTML, however, it may not work as effectively

I am trying to implement a functionality using jquery to fetch data from a PHP script and display it on the same page. However, I am facing an issue where I only get "0 Results" when I use jquery to call the data, but when I submit the form, I receive the ...

How to Perfectly Position Content with Bootstrap 3's Full Width Image Carousel

Here's my query: Is there a way to adjust the position of my content (such as text) inside the slider responsively? The text can be positioned anywhere within the Div Slider, for example, at 25% from the left and 50% from the top within the Image Di ...

What is the best way to link a URL ID to a specific piece of content stored on

Is it possible to display a product without creating separate html pages for each one using unique IDs? I prefer the layout style of Pinterest. For example, with a URL like /product/12345 When a user clicks on /product/12345, the content should be rende ...

centering an angular material card on the webpage

Currently, I have developed a Registration script that enables users to Sign Up on my website. However, the issue I am facing is that the angular material card, which houses the sign up interface, is not centered. Despite trying various methods such as & ...

Every time I implement *ngSwitch in a Bootstrap navbar, the visual styling unexpectedly vanishes

<ul class='nav navbar-nav'> <li class='nav-item'> <ul [ngSwitch]='isLoggedIn' class='nav-item'> <li *ngSwitchCase=true> ...

The positioning of inline block elements is not aligned correctly

Can anyone shed light on why my text is causing the block element to move downward? Removing the text aligns the block elements perfectly. <div class="item-0" align="center"> <div class="row"> <div class="col-lg-12"> ...

When you click on links and buttons, a focus outline appears

I am currently troubleshooting an issue within an existing application that relies on the use of jQuery. The problem arises when I click on any link or button on the page, causing the element to display a focus outline (such as a blue glow in browsers like ...

Can you explain the distinction between using element~element versus element+element?

Can you explain the variation between these two CSS selectors? When using them, I seem to receive the same outcome. In the HTML: <div>One</div> <p>Two</p> CSS Example #1: div+p { background:red; } This code assigns a red backgr ...

Utilize a dynamic URL within the HTML audio element

Currently, I am working with the use of the audio tag in HTML and AngularJS. I need to specify the source of the audio file I want to play, as shown below. <audio src="http://localhost/audio/221122/play/212223.mp3" audio player controls p ...

Tips for getting around the router in Angular 2

We have multiple template files containing their components, each with defined routes that can be called using the following syntax: <a routerLink="/Path-with-component"> Open page with component </a> In addition to these dynamic components, ...

Having issues with jQuery input values not being recognized on form submission

I have all my data prepared and ready to be saved in my database. However, I am encountering an issue where no data is being picked up when I hit submit. The data is generated from my JavaScript file using the .append() method. Below is the HTML structure ...