The behavior of flex with overflow and bootstrap navbar varies across Firefox, Chrome, and Safari

When I view the snippet below in Firefox, I notice that the div with the class h-100 is taking up the entire page height (100vh), resulting in an unnecessary second scroll bar due to the added height of the nav.

What I really want is for only the div with overflow-y: auto to have a scrollbar.

Interestingly, this issue doesn't occur when I test it in Chrome and Safari.

Could there be something wrong with my HTML/CSS, and how can I resolve this inconsistency across browsers?

.grey {
  background-color: grey;
}

#foo {
  background-color: red;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>

<div id="root">
  <div style="height: 100vh; display: flex; flex-direction: column">
    <nav class="navbar navbar-dark navbar-expand bg-dark"><a class="navbar-brand" href="/">Title</a></nav>
    <div class="h-100" style="display: flex; flex-direction: row">
      <div style="flex: 1 1 auto; overflow-y: auto">
        <div id="foo" style="height: 1200px">
        </div>
      </div>
    </div>
  </div>
</div>

Answer №1

To ensure the content remains within bounds, apply the overflow hidden property to the parent container.

.grey {
  background-color: grey;
}

#foo {
  background-color: red;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>

<div id="root">
  <div style="height: 100vh; display: flex; flex-direction: column">
    <nav class="navbar navbar-dark navbar-expand bg-dark"><a class="navbar-brand" href="/">Title</a></nav>
    <div class="h-100" style="display: flex; overflow: hidden; flex-direction: row">
      <div style="flex: 1 1 auto; overflow-y: auto">
        <div id="foo" style="height: 1200px">
        </div>
      </div>
    </div>
  </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

Having trouble properly implementing variable updates when creating a multi-theme website

I have a Next.js app and a globals file containing all the themes: body { margin: 0; font-family: Inconsolata, monospace; background-color: var(--bg-color); } :root { --bg-color: #262a33; --main-color: #43ffaf; --sub-color: #526777; --sub-al ...

Configuring various options on numerous dropdowns using AngularJS

I am looking for a solution to customize dropdowns created through ng-repeat in AngularJS. The number of dropdowns displayed is determined by the data fetched from the database. I want to be able to set an initial option value for each dropdown based on th ...

Tips for including a permanent button at the bottom of a material ui dialog box

I want to implement a dialog popup in my react js application. When the user clicks on a button, the dialog should open up. Inside the dialog, there is a form with input fields. After the user fills out all the inputs, they can submit the information by cl ...

resizing a big image to perfectly fit the width of the screen with the help of

Is there a way to use AngularJS to automatically adjust the size of a large image to fit the screen on various devices (responsive), similar to how it is done on this website? Are there any Angular directives available for this purpose, or would I need to ...

What's the best way to include CSS and Javascript in an HTML document?

I'm still getting the hang of CSS and JavaScript. I stumbled upon a cool countdown timer that I'd like to incorporate into my website, but I'm not quite sure how to place it where I envision it. Check out the timer here CSS: html,body{mar ...

Is it true that using <meta charset="utf-8"> specifies the character encoding of the document

According to what I've learned, an HTML document must include the <meta charset="utf-8"> element within the head section in order to be considered standard-compliant. What is the logic behind indicating the encoding of a file within the file it ...

modifying the width of the primary container following the display or concealment of an alternate container

I am working on a main div that contains two separate divs for main content and sidebar content. The sidebar content can be hidden or shown by clicking a link. When the sidebar is hidden, I want the content div to occupy the entire space within the conta ...

HTML/JS Linking Tool

I'm new to HTML and JavaScript, coming from a background in Python. I'm working on a program where you enter a link into an HTML form and when you click a button, it's supposed to take you to that link. However, when I click the button, the ...

Is there a way to transform Python's JSON object into an HTML table?

Creating a webpage using Flask and encountering some issues with Python syntax: @app.route('/uploads/<filename>') def uploaded_file(filename): reader = shapefile.Reader("./uploads/"+filename) fields = reader.fields[1:] field_names = ...

Tips for creating an empty column in each succeeding row of a grid layout

Is there a way to create a grid layout with divs that leave space on the left side of each subsequent row? For example, having 4 div boxes in the first row, 3 in the second, 2 in the third, and so on. Demo https://i.sstatic.net/Gli6L.png Styling in CSS ...

Create a hover effect on HTML map area using CSS

Is it possible to change the background color of an image map area on hover and click without using any third-party plugins? I attempted the following code: $(document).on('click', '.states', function(){ $(this).css("backgro ...

The html select option tag is automatically closed because of the presence of the "/" character within the dynamic value in JSP and JSTL

<select id="ordersSelect" class="drop-down" onchange="somemethod()"> <c:forEach items="${orders}" var="order" varStatus="orderStatus"> <option value="${order.id}"> ${order.publicId} </option> </c:forEach> </select> ...

Exciting transition effect for font sizes in CSS

Issue: Hover over the X and wait for the div to collapse completely. Move away from the X Notice how the div jumps to the bottom and then back up. Inquiry: How can I prevent text wrapping while expanding the div during animation? (Currently using del ...

Designing unique icons through image manipulation in CSS

I am currently experimenting with creating an icon that functions similar to font-awesome. When I apply a specific class, it should display an image based on the font size. Surprisingly, I got it to work in Chrome but for some reason, the same code doesn&a ...

Crafting CSS for styling input type file elements

My attempts to style the input type file with CSS have been unsuccessful. In my current code, the "choose file" button is displaying above my styled button. How can I use CSS to remove this? I am aiming to only display a blue colored button for uploading ...

Execute CSS within jQuery code only when the body class is present

I am attempting to use CSS (display: none;) within a script to hide elements from my menu only if a specific language is active. When the body class changes from one language to another, I want the script to check if the body class of a certain language ...

Add a css class to a <div> that is created by an <ng-template> inside the <ngx-datatable-column> element

I am struggling to implement the display: flex style on the parent <div> containing my <span> However, since the <span> is dynamically generated by the ng-template of the ngx-datatable-column, I'm finding it challenging to apply thi ...

Create a uniform Bootstrap 5 album grid showcasing various text lengths for a visually cohesive display

Currently, I have designed a bootstrap album which can be viewed here: https://getbootstrap.com/docs/5.0/examples/album/ However, the text displayed in my album varies in length, resulting in an uneven layout like this: https://i.sstatic.net/Qwrnx.png ...

Looking for a solution to resolve the error in this SQL example?

I'm looking to extract node "-all_models=1-4.htm" in SQL using the example provided. Here is my current code: <div class="models_selector_block" > <DIV class="msb_item"> <a class="ser_active" hr ...

Adjust the Size of Bootstrap 4 Dropdown Caret Icon

Currently, I am using the Bootstrap v4 framework on my HTML page. I am looking to resize or increase the caret size in my dropdown list. Does anyone have any tips on how to accomplish this? https://i.sstatic.net/kCNPK.png Below is the code snippet: < ...