Disable the horizontal scrollbar on the x-axis within the Bootstrap 5 grid system

I am attempting to create a layout similar to Stack Overflow in Bootstrap 5. I am using only the Bootstrap grid and not other utility classes (using Sass),

@import "../node_modules/bootstrap/scss/grid"

This layout includes a fixed header, fixed left sidebar, and scrollable main content (which contains post content and a footer)

Note: In the example code, I have used a few helper classes which will be taken care of later. This is just for demonstration purposes...

Problem: An unwanted x-axis scrollbar appears (see example code below). This issue needs to be resolved...

Before asking, I have already tried multiple solutions but have not been able to resolve it. If the answer is already available here, please provide the link and I will delete my question

 
header {
    position: fixed;
    top: 0;
    height: 50px;
    background-color: rebeccapurple;
}           
#sticky-sidebar {
    position: fixed;
    height: calc(100vh - 50px);
    top: 50px;
    max-width: 20%;
    background-color: red;
}
main{
    min-height: 100vh;
}
footer{
    min-height: 100px;
}
                
            
 
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">

<div class="container-fluid g-0">
    <div class="row">
        <header>
            <div class="col-md-12">
                Header
            </div>
        </header>
    </div>
</div>

<div class="container-fluid g-0">

    <div class="row">
        <div class="col-xs-4">
            <div class="col-xs-12" id="sticky-sidebar">
               Menu
            </div>
        </div>
        <div class="col-xs-8 p-5" id="main">
            <main>
                <p>
                    Lorem ipsum dolor sit amet consectetur adipisicing elit...
                </p>
            </main>
            <footer style="text-align: center;">
                &copy; Footer 2021 
            </footer>
        </div>
    </div>
</div>
                
            

Answer №1

It is highly recommended to consult the documentation as there are several issues with the current markup. Bootstrap 5 beta follows the same grid guidelines as Bootstrap 4...

  • rows act as containers for columns. Therefore, only columns should be nested within rows, and columns should not be placed directly inside other columns.

  • g-0 (no gutters) should be applied to the row, not the container

  • There is no longer an -xs infix. For instance, use col-12 instead of col-xs-12

<header>
    <div class="row">
        <div class="col-12">Header </div>
    </div>
</header>
<div class="container-fluid">
    <div class="row g-0">
        <div class="col-4">
            <div class="row">
                <div class="col-12" id="sticky-sidebar"> Menu </div>
            </div>
        </div>
        <div class="col-xs-8 p-5" id="main">
            <main>
                <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Illum maiores, molestiae porro numquam aperiam dignissimos iste quisquam quidem saepe voluptatibus possimus eum. Aut nihil maiores harum, voluptate dicta veniam quo, praesentium id ipsa esse eaque numquam cupiditate assumenda consectetur accusamus maxime ea reiciendis ut? Ut consectetur quis, sapiente, rem consequuntur architecto sit quasi dignissimos nisi nihil, tenetur necessitatibus. Veritatis, harum eaque. Quae odio repellendus architecto magni, excepturi reprehenderit, odit dolor, illum quis nulla porro? Pariatur, amet architecto sint illum, molestiae non optio quis facere deserunt nostrum reiciendis omnis illo velit dolores ex corpor...
            </main>
            <footer style="text-align: center;"> &copy; Footer 2021 </footer>
        </div>
    </div>
</div>

Live Demo

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

The drop-down menu is malfunctioning as it is not displaying the complete text and the

At the moment, I am facing an issue where my submenu items for Add Subject, Drop Subject, and Delete Subject are not centralized as intended. Additionally, the Executive Summary text in the submenu is getting cut off. Can someone please help me with expand ...

Customizing jquery mobile styling

I am dealing with a table where the challenge lies in aligning the text to center in the header. .info-header { font-size: small; text-align: center; } Despite setting the alignment, the row still inherits left alignment from jQuery mobile. Seeking ...

Shades of Grey in Visual Studio Code

Whenever I use VSC, I notice these odd grey boxes that appear in my editor. They seem to be dynamic and really bother me. Interestingly, switching to a light theme makes them disappear. However, I prefer using a dark theme and haven't been able to fin ...

Steps for reverting a widget's background color to its default state following the utilization of gtk_css_provider_load_from_data()

Previously, I would adjust the background colors of widgets using gtk_widget_override_background_color. However, this function is no longer supported, so I am looking to migrate to utilizing GtkCssProvider. I have discovered that I can modify the backgrou ...

Displaying a video in fullscreen on a webpage

Struggling to achieve the desired result, seeking advice from experts. Looking to create a classic example like this: http://codepen.io/anon/pen/rWwaRE But want it embedded within blocks of text and possibly triggered by scrolling over it similar to this ...

Incorporating a transparent icon onto an HTML background

I'm struggling to place a transparent white envelope icon on a green background. I don't understand why it's not working, especially when the telephone icon worked fine. Side Question.: Any recommendations for how to add something above the ...

Guide on inserting text within a Toggle Switch Component using React

Is there a way to insert text inside a Switch component in ReactJS? Specifically, I'm looking to add the text EN and PT within the Switch Component. I opted not to use any libraries for this. Instead, I crafted the component solely using CSS to achie ...

Check out this stylish Twitter-inspired SVG text counter created with a combination of CSS and jQuery! See it in action here: https://jsfiddle.net/moss24

Looking to develop a text counter similar to Twitter that increases the width in green color up to 75%, then switches to yellow until 98%, and finally turns red if the input value is greater than or equal to 400. It should also add a "highlight" class when ...

The JQuery code is failing to remove the dynamically added field when the delete icon is clicked

Information: I am currently navigating the world of programming and attempting to build a To-Do List feature. When the create list button is clicked, a dynamically generated div with the class 'wrap' is created. This div contains two nested divs: ...

The custom styling in custom.css is not taking precedence over the styles defined in

My site is experiencing some element overwriting when I include css/bootstrap.min.css, such as 'a' tags, the .nav bar, and fonts used on the site. Load order: <link href="css/bootstrap.min.css" rel="stylesheet"/> <link rel="styleshe ...

How does margin:auto differ from using justify-content and align-items center together?

If you want to center both horizontally and vertically at the same time, there are two easy methods available: Option One .outer { display:flex; } .inner { margin:auto; } Option Two .outer { display: flex; justify-content: center; align-items ...

1. "Customizing Navbar height and implementing hover color for links"2. "Tips for

Having issues adjusting the height of my Navbar - when I try to do so, the collapse button doesn't function properly. I've attempted setting the height using style="height: 60px;" and .navbar {height: 60px;} but the collapse menu stops ...

Drop-down functionality in Bootstrap Form becomes unresponsive after screen width is decreased

I recently encountered a strange issue with my simple Bootstrap form. When I resize my browser width to mobile size or view it on a mobile device, the form stops functioning properly. Unfortunately, I am unable to provide any specific code examples at this ...

What is the best way to place an element above another without disrupting the layout of the document?

I have a scenario where I am layering a black div on top of a red div using absolute positioning. Subsequently, additional content is displayed. p { position: relative; z-index; 10 } .wrapper { position: relative; } #red { height: 300px; w ...

Wrapping content in flexbox and aligning it justified

I have an issue where I want to display a page title on the left side and a rating number with stars on the right side. My goal is to center all items once flexbox wraps. Specifically, when the "Longer Page Title" reaches the rating and stars and the flexb ...

What is the best way to retrieve the border-color inline style using jQuery?

I have a HTML tag like this. <span id="createOrderFormId:accountNo" style="border-color: red;"><</span> To retrieve the style value for the border-color property, I tried using the following jQuery code: $( document ).ready(function() { ...

What is the best way to remove the box-shadow from a React-Bootstrap Dropdown Button?

I'm attempting to remove the box shadow or second border from the bootstrap dropdown button when it is clicked. I have been unable to identify the specific class responsible for this change. https://i.sstatic.net/9wxRm.png ...

How can I use jQuery to vertically align an element?

Here's my website: Take a look here! I have a menu on the left column that I want to center. Take a look at the image below for a better understanding of what I'm trying to achieve. https://i.stack.imgur.com/ZzprT.png Here is the JavaScript c ...

The process of running npx create-react-app with a specific name suddenly halts at a particular stage

Throughout my experience, I have never encountered this particular issue with the reliable old create-react-app However, on this occasion, I decided to use npx create-react-app to initiate a new react app. Below is a screenshot depicting the progress o ...

Tips for designing the microphone appearance on the Google Chrome speech input interface

Google Chrome features an input control for speech recognition. If you want to know how to use it, check out this link. I'm looking to enlarge the microphone icon and possibly use a customized image for it. Increasing the width and height of the inp ...