The layout of Bootstrap 4.1 exceeds the width of the page

I've recently switched to using Bootstrap 4.1 for my website, but I'm facing an issue with the grid-layout being wider than the page itself. This forces users to scroll sideways to view the entire grid.

Here's a snapshot of how the page looked before implementing the Grid-System: https://ibb.co/y8RWGqY

And here's how it appears after integrating the Grid-System: https://ibb.co/LPP0TsL

.carousel-item {
  height: 100vh;
  min-height: 350px;
  background: no-repeat center center scroll;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

.logo {
  position: absolute;
  top: 0;
  left: 0;
}

.logo img {
  max-width: 150px;
  max-height: 150px;
}

.titulo {
  display: inline;
  font-family: 'Montserrat', sans-serif;
  font-size: 60px;
  font-weight: 700;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>


<header>
  <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
    <ol class="carousel-indicators">
      <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
      <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
      <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
    </ol>
    <div class="carousel-inner" role="listbox">
      <!-- Slide One - Set the background image for this slide in the line below -->
      <div class="carousel-item active" style="background-image: url('https://source.unsplash.com/LAaSoL0LrYs/1920x1080')">
        <div class="carousel-caption d-none d-md-block">
          <h2 class="display-4">First Slide</h2>
          <p class="lead">This is a description for the first slide.</p>
        </div>
      </div>
      <!-- Slide Two - Set the background image for this slide in the line below -->
      <div class="carousel-item" style="background-image: url('https://source.unsplash.com/bF2vsubyHcQ/1920x1080')">
        <div class="carousel-caption d-none d-md-block">
          <h2 class="display-4">Second Slide</h2>
          <p class="lead">This is a description for the second slide.</p>
        </div>
      </div>
      <!-- Slide Three - Set the background image for this slide in the line below -->
      <div class="carousel-item" style="background-image: url('https://source.unsplash.com/szFUQoyvrxM/1920x1080')">
        <div class="carousel-caption d-none d-md-block">
          <h2 class="display-4">Third Slide</h2>
          <p class="lead">This is a description for the third slide.</p>
        </div>
      </div>
    </div>
    <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
      <span class="carousel-control-next-icon" aria-hidden="true"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>
</header>

<div class="logo">
  <img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="W3Schools.com">
</div>

<br><br><br>

<main style="text-align: center;">
  <div class="titulo">Quem somos</div>
</main>

<div class="row">
  <div class="col-4" style="background-color: red;"><br><br><br><br><br></div>
  <div class="col-8" style="background-color: blue;"><br><br><br><br><br></div>
</div>

Answer №1

To ensure that the grid container spans 100% width, it is recommended to utilize the container-fluid class.

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
   
<div class="container-fluid">
    <div class="row">
        <div class="col-4" style="background-color: red;"><br><br><br><br><br></div>
        <div class="col-8" style="background-color: blue;"><br><br><br><br><br></div>
    </div>
</div>

Answer №2

It is essential to keep in mind that all content should be enclosed within a div using either the container or container-fluid class, as shown below:

<div class="container">
your code goes here...
</div>

Answer №3

To eliminate the scroll, you can either add the container-fluid class above the row div or simply insert the m-0 class directly into the row.

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
            <ol class="carousel-indicators">
                <li data-target="#carouselExampleIndicators" data-target="#mycarousel" data-slide-to="0" class="active"></li>
                <li data-target="#carouselExampleIndicators" data-target="#mycarousel" data-slide-to="1"></li>
                <li data-target="#carouselExampleIndicators" data-target="#mycarousel" data-slide-to="2"></li>
            </ol>
            <div class="carousel-inner" role="listbox">
                <!-- Slide One - Set the background image for this slide in the line below -->
                <div class="carousel-item active" style="background-image: url('images/c1.jpg')">
                    <div class="carousel-caption d-none d-md-block">
                        <h2 class="display-4">First Slide</h2>
                        <p class="lead">This is a description for the first slide.</p>
                    </div>
                </div>
                <!-- Slide Two - Set the background image for this slide in the line below -->
                <div class="carousel-item" style="background-image: url('images/c2.jpg')">
                    <div class="carousel-caption d-none d-md-block">
                        <h2 class="display-4">Second Slide</h2>
                        <p class="lead">This is a description for the second slide.</p>
                    </div>
                </div>
                <!-- Slide Three - Set the background image for this slide in the line below -->
                <div class="carousel-item" style="background-image: url('images/c3.jpg')">
                    <div class="carousel-caption d-none d-md-block">
                        <h2 class="display-4">Third Slide</h2>
                        <p class="lead">This is a description for the third slide.</p>
                    </div>
                </div>
            </div>
            <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="sr-only">Previous</span>
            </a>
            <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="sr-only">Next</span>
            </a>
        </div>
    </header>

    <div class="logo">
        <img src="images/logo.png">
    </div>

    <br><br><br>

    <main style="text-align: center;">
        <div class="titulo">Quem somos</div>
    </main>
<div class="container-fluid">
    <div class="row">
        <div class="col-4" style="background-color: red;"><br><br><br><br><br></div>
        <div class="col-8" style="background-color: blue;"><br><br><br><br><br></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

MUI: Interaction with a button inside a MenuItem when not interacted with MenuItem itself?

Currently, I am utilizing MUI's Menu / MenuItem to create a menu of missions / tasks similar to the screenshot below: https://i.sstatic.net/6FGrx.png The MenuItem is interactive: // ... other code <MenuItem value={mission.issu ...

Execute JavaScript function when the page is being refreshed or accessed from an external link

On the Home page, we have a special Lottie animation that serves as a preloader. This animation should only display under certain conditions: Accessing the home page by clicking on a link from an external page (not on your website) Refreshing the brow ...

What could be causing this element to not float left in Firefox?

Can anyone help with aligning a checkbox to float left in Firefox? I can't seem to figure out what's causing the issue. Example that demonstrates the issue: http://jsfiddle.net/3zhrD/ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional ...

What could be causing the issue of AJAX and PHP script not returning to the original form after posting

I've set up a form with Ajax to send data to a simple PHP script for troubleshooting purposes, but I'm facing an issue where the data is not being posted back to the original HTML form. Below are the two scripts: <!DOCTYPE html> <htm ...

The alignment of Bootstrap text is not in alignment

Hi there, I am pretty new to bootstrap and have been hunting for a solution regarding this specific layout that I want to achieve. Check out the image below: https://i.sstatic.net/qqaCo.png The issue I am facing is that in my code, the name, code, status, ...

The use of Stack Navigation results in a dual-header display

Currently, I am in the process of developing an app using React-Native for the first time. While working on this project, I encountered an issue. In my navigation setup, I have three main options. The first option is my main home screen where I want to h ...

Exploring Data in ASP.NET Resource Files

I currently have an HTML file located in Resource1.resx. My goal is to retrieve the content of this HTML file using a StreamReader. What steps should I take to achieve this? Here is the HTML file content: <html> <body> <table> < ...

Why is gh-pages not recognizing the project directory while looking for resources?

I've encountered an issue with my website that functions perfectly fine locally but when deployed on gh-pages, it results in several 404 errors while attempting to retrieve resources. One such example is a line of CSS for setting the background: back ...

Styling with CSS: Using a Base64 Encoded Image in the Background URL

Can a Base64 encoded image be loaded as a background image URL without exposing the actual encoded string in the page source? For example, if a Node API is used to GET request at "/image", it returns the serialized Base64 data. res.json("da ...

How come the ng-click inside ng-repeat is not triggering the function as expected?

Attempting to execute a function in a clientside controller file by utilizing ng-click on a button within my HTML. Unfortunately, I am not receiving any output and cannot determine the cause of the issue. Any assistance would be greatly appreciated. HTML ...

Ways to ensure a ul li element perfectly fits inside a div element without any spaces

As a newcomer to CSS and HTML, I'm facing an issue with my ul li dropdown menu and login boxes. The background colors are red and blue, but there are gaps within the div that I want to fill with the height of the div. Below is the code snippet: @key ...

The background image shifts dynamically with a parallax effect as the page is scrolled

I need help solving a parallax issue that I'm currently facing. On my webpage, I have a background image positioned at the top with a parallax effect achieved through background-position: fixed. However, I now require the image to scroll along with t ...

When the screen is minimized, my website doesn't align to the center as expected

When the screen is maximized everything looks great, but when I minimize it, the content doesn't center. I tried using margin: auto; in the "main-div" class, but then everything shifted to the top left corner. So, I added a "wrapper-div" to contain th ...

jQuery UI Accordion - Adjusting Panel Height to Content Size

Currently, I am utilizing jQuery UI's Accordion feature from http://jqueryui.com/demos/accordion/, and my goal is to adjust it so that it resizes based on the contents of each panel rather than just fitting the largest one. In addition, I am seeking ...

Arrange Bootstrap columns based on the available space within a loop

The content is contained within a md-8 div and generated through a PHP loop. The loop includes sections for: 1. about us 2. areas we cover 3. job board 4. candidates 5. join us 6. contact Due to the limited height of the "areas we cover" section, th ...

Enhancing the appearance of unordered lists with CSS. Creating numbered lists

Here is a list that I am currently working with: <ul> <li>question1</li> <li>answer1</li> <li>question2</li> <li>answer2</li> </ul> I have applied the following CSS styling: ul { ...

What is the best way to verify reCAPTCHA v2 on an HTML website?

The code I'm using is giving me an error when the page loads: Cannot connect to reCAPTCHA. Please check your connection and try again. Just a reminder, I won't be incorporating any server-side code on my website. It's a simple HTML setup ...

Increase the gap between columns in Bootstrap for a better layout

I have implemented a web layout using bootstrap 3. You can view the JSFiddle here. In order to make the layout responsive, I had to structure it in a slightly unconventional way. The final output on small screens includes three information boxes within an ...

Tips for comparing URLs of the current active tab

Looking to create an adblocker specifically for a certain website. I have successfully implemented code that removes ads on the homepage, but it is still affecting other pages such as movie pages. This results in the deletion of the information section, i ...

Looking for an HTML tag in BeautifulSoup that contains exactly one attribute

I am working on a website in HTML and need to extract specific data from it. The HTML structure is as follows: <p class="provice hidden-xs"> <span class="provice-mobile">NEW YORK</span> witespace <span class="provice-mobile" style="co ...