A unique flex layout with scrolling capabilities specifically designed for optimal performance in Chrome

This layout includes a header, footer, sidebar, and a scrolling main content section. You can view a demonstration of this design on Bootply.

<div class="parent">
  <div>HEADER</div>
  <div class="main">
    <div class="side">
      SIDE
    </div>  
    <div class="inner-main">
      MAIN
      <ul>
        <li>testing 1.. 2.. 3..</li>             
        <li>testing 1.. 2.. 3..</li>
        <!-- and so on... -->
      </ul>
    </div>
  </div>
  <div>FOOTER</div>
</div>

The CSS for this layout is as follows:

body {
    height: 100vh;
    width: 100%;
    display: flex;
}
div.main {
    display: flex;
    flex-direction: row;
    flex: 1 1 auto;
}
div.parent {
    display: flex;
    flex-direction: column;
    background-color: green;
    flex: 1 1 auto;
}
div.side {
    background-color: #454545;
}
.inner-main {
    background-color: pink;
    flex: 1 1 auto;
    overflow-y: scroll;

}

In Chrome, the scrolling feature works correctly without an outer scrollbar. However, in other browsers, such as Firefox and Internet Explorer 11, an outer scrollbar may appear and affect the display of the footer.

If you want to correct this issue and ensure that the inner scroller handles the overflow properly in Firefox and optionally IE11, consider making adjustments to the CSS.

Answer №1

One potential solution involves using the height:100vh property on the main element.

/* Custom CSS code follows after bootstrap.css */
body {
    width: 100%;
    display: flex;
    overflow:hidden;
    margin:0;
}
div.main {
    display: flex;
    flex-direction: row;
    flex: 1 1 auto;
}
div.parent {
    display: flex;
    flex-direction: column;
    background-color: green;
    flex: 1 1 auto;
}
div.side {
    background-color: #454545;
}
main {
    background-color: pink;
    flex: 1 1 auto;
    overflow-y: scroll;
    /* height: 100vh; */
    height: calc(100vh - 40px); /* viewport height - (header, footer) height */
}
<div class="parent">
    <div>HEADER</div>
    <div class="main">
        <div class="side">
            SIDE
        </div>
        <main>
            MAIN
            <ul>
                <li>testing 1.. 2.. 3..</li>             
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
                <li>testing 1.. 2.. 3..</li>
            </ul>
        </main>
    </div>
    <div>FOOTER</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

Why is it that when I refresh the page in Angular, my logged-in user is not being recognized? What could be causing this

I am developing a Single Page Application using the combination of Angular JS and Node JS. In my HTML file, I have defined two divs and based on certain conditions, I want to display one of them using ng-if. However, I noticed that the model value used in ...

Exploring CSS3 for Creating Stylish Navigation Bars

Currently, I am attempting to design a Navigation bar that resembles the style shown in this image, complete with a drop-down menu feature. Here is how I have structured my menu: <nav> <ul> <li> <a href="/i ...

I'm searching for the HTML5 specifications and information on which browsers support specific features. Can you point me in the right direction

Where can I locate the HTML5 specifications for Internet Explorer, Opera, Firefox, and Google Chrome browsers? ...

Tips for resolving the issue of the symbol ' displaying as &#39 in an Angular 2 application

I am currently working on an Angular application that makes API calls when a name displayed in a grid table is clicked. However, I have encountered an issue where names containing an apostrophe are being displayed incorrectly as &#39 instead. I managed ...

Emphasize the checkbox

In my table, I have radio buttons that should turn the neighboring cell green when clicked. Using JQuery, I added a "highlight" class on $.change event to achieve this effect. However, I encountered an issue where some radio buttons load with the "checked ...

A guide to implementing div wrapping in HTML

I'm in the process of using flexbox on my website. I have 10 div elements that I want to wrap around each other closely without any gaps between them. My goal is to have "4" positioned to the right of "1", instead of creating a new row and moving dow ...

Set up a JavaScript function that triggers an alert if two numbers are determined to be equal

I created a code snippet that should display an alert message when a button is clicked, indicating whether two random numbers generated are equal or not. The random numbers must be integers between 1 and 6. I implemented this functionality in JavaScript bu ...

The fixed table header is misaligned with the body columns' width

I was looking for a way to add a vertical scrollbar to my table, and I ended up wrapping the entire table in a div. The result was that the table head was fixed in position. Is there a simpler method to include a scrollbar in a table without affecting the ...

Having trouble understanding how to display an HTML file using Next.JS?

Currently, I am working on a project that involves utilizing Next.JS to develop a webpage. The main goal is to display a PDF file on the left side of the screen while integrating Chaindesk on the right side to create a chat bot capable of extracting inform ...

Replacing text within nested elements

I am facing an issue with replacing certain elements on my webpage. The element in question looks like this: <div id="product-123"> <h3>${Title}</h3> <div> ${Description} </div> <div> ${P ...

Can you modify the current HTML code of a Wix website?

I am currently developing a website using Wix and have encountered an issue with the page description. Despite editing it in Wix, the changes are not reflecting on the live site. Upon inspecting the source code in Chrome, I identified the problem lies wi ...

Executing a JavaScript/jQuery function on the following page

I'm currently working on developing an internal jobs management workflow and I'd like to enhance the user experience by triggering a JavaScript function when redirecting them to a new page after submitting a form. At the moment, I am adding the ...

The total sum of various divs containing a mix of numbers and letters

I have a group of div elements with the same class, each containing a value in the format (X1), (X2),... I need to add up these numeric values only, like 1 + 2 + .... Since these divs are generated dynamically, I won't know how many there will be. How ...

Tricking Vuejs into triggering a @change event

I possess the following: <input type="radio" :name="activity" v-model="activity" :value="1" v-on:change="callProc(data, data2)" required> Ho ...

Implementing interactive dropdown menus to trigger specific actions

I have modified some code I found in a tutorial on creating hoverable dropdowns from W3. Instead of the default behavior where clicking on a link takes you to another page, I want to pass a value to a function when a user clicks. Below is a snippet of the ...

Enhance your web forms with jQuery Chosen's automatic formatting feature

Having trouble adding a feature to my multi-select input box using jQuery Chosen. The current functionality allows users to enter custom values not in the list. The new feature should automatically format numbers entered by users, for example: User input ...

Can someone guide me on how to make a Carousel responsive using Angular?

HTML: <div class="voxel-row"> <div class="voxel-col-4"><h2 id="vagas_recentes">vagas recentes</h2></div> </div> <div id="carouselExampleControls" cl ...

Content in Slider Exceeding Container Bounds

After successfully creating a slider using jQuery with the help of some Stack Overflow users, everything was working perfectly. However, when attempting to change the layout of the slider, it somehow broke and now all slides are being pushed out of the con ...

Prioritize the first child in Flexbox by truncating its text before the second

I am working with a flex-box container named .search-bar, which contains two divs with text, labeled as .title. My goal is to make the second child take up any extra space available and only start ellipsizing when there is no more space left for the first ...

Bug with the button and text input feature in Firefox

I am facing a strange issue where the button and input have the same CSS (except for the background), but Firefox is displaying them differently. This problem does not occur in IE or Chrome. #searchInput { width: 80%; margin: 0 auto; display: ...