The Bootstrap column is causing a cropping issue on the left side of my rows

I'm currently working on a Python/Flask/HTML project that utilizes Bootstrap 4 for a grid system with multiple rows and columns. However, when I attempt to run the project, a few pixels get cut off on the left side of the screen. I've thoroughly checked my code but still can't figure out the reason behind this issue. If anyone could provide some help, I would greatly appreciate it! Here is a jsfiddle containing my code, as well as a hard copy. Thank you in advance for your assistance!

<!DOCTYPE html>

<!-- Link to css file -->
<link rel="stylesheet" type="text/css" href="/static/main.css" mesdia="screen"/>

<!-- Bootstrap CDN-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

<meta charset="UTF-8">
<title>Layout</title>
<!--<h1>Welcome to the layout</h1>
<p>Where would you like to navigate to?</p>-->

<div class="row" id="navcols">

    <div class="col">
        <div class="row h-50">Row</div>
        <div class="row h-50">Row</div>
    </div>


    <div class="col-sm-6">
        <div class="row h-100">Row</div>
        <div class="row h-100">Row</div>
        <div class="row h-100">Row</div>
        <div class="row h-100">Row</div>
        <div class="row h-100">Row</div>
    </div>

    <div class="col">
        <div class="row">Row</div>
    </div>

</div>

<!--
<div class="container-fluid">
    <h1 id="test">Welcome to my page! Where do you want to navigate to?</h1>
</div>-->

    html,body {
  height: 100%;
  width: 100%;
}

.col {
    background-color:red;
}

Answer №1

When working with Bootstrap layout, it is essential to enclose your row and col elements within a div that has the class of container or container-fluid. If you require a full-width column, then you should utilize container-fluid. The difference lies in the fact that container has a maximum width set in pixels, whereas container-fluid has a max-width of 100%. container-fluid will resize dynamically as you adjust the width of your window or browser. :

html,
body {
  height: 100%;
  width: 100%;
}

.col {
  background-color: red;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

<div class="container-fluid">

  <div class="row" id="navcols">

    <div class="col">
      <div class="row h-50">Row</div>
      <div class="row h-50">Row</div>
    </div>


    <div class="col-sm-6">
      <div class="row h-100">Row</div>
      <div class="row h-100">Row</div>
      <div class="row h-100">Row</div>
      <div class="row h-100">Row</div>
      <div class="row h-100">Row</div>
    </div>

    <div class="col">
      <div class="row">Row</div>
    </div>
  </div>

</div>

Answer №2

Enclose your row class div within a container or container-fluid class div.

<div class='container'>
  <div class='row'>
    <!--place your grid here-->
  </div>
</div>

Answer №3

To enhance the structure of your HTML, consider adding either the .container or .container-fluid class to the parent div.

<div class="container">

<div class="row" id="navcols">

    <div class="col">
        <div class="row h-50">Row</div>
        <div class="row h-50">Row</div>
    </div>


    <div class="col-sm-6">
        <div class="row h-100">Row</div>
        <div class="row h-100">Row</div>
        <div class="row h-100">Row</div>
        <div class="row h-100">Row</div>
        <div class="row h-100">Row</div>
    </div>

    <div class="col">
        <div class="row">Row</div>
    </div>

</div>

</div>

Answer №4

Your Bootstrap class is causing a -15px margin from the left and right, resulting in the screen being cut off. To resolve this issue, simply adjust the margin to 0.

<div class="row" id="navcols" style="margin-left:0; margin-right:0;">

    <div class="col">
        <div class="row h-50">Row</div>
        <div class="row h-50">Row</div>
    </div>


    <div class="col-sm-6">
        <div class="row h-100">Row</div>
        <div class="row h-100">Row</div>
        <div class="row h-100">Row</div>
        <div class="row h-100">Row</div>
        <div class="row h-100">Row</div>
    </div>

    <div class="col">
        <div class="row">Row</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

Enable the image to extend beyond the boundaries of its containing div

How can I prevent a div from extending its width, allowing an image to be visible outside of it in IE8? Specifically, my div may be 200px wide while the image is 250px wide. ...

Unable to insert flag image into the <option> tag

Struggling to add a flag image to the options using any method (html,css)! <select> <option value="rus" selected>Rus</option> <option value="Uzb" >Uzb</option> <option value="eng">Eng</option> </s ...

Tips for resolving the error "Invalid value for style prop - must be an object" in a React.js and CSS scenario

Hey there, I'm currently working with module.css in React and facing an issue when trying to include the following line: <span style="--i:1;"><img src="https://i.postimg.cc/BQcRL38F/pexels-photo-761963.jpg" alt="not f ...

Calculate the dimensions of each list item and dynamically increase the size of the unordered list with jQuery

Trying to extract the 'width' style attribute from li and assign it to ul. The HTML code looks like this: <div id="carousel_team" class="glide"> <ul class="slides" style="opacity: 1; width: 1464px;"> <li class="slide first active ...

Unable to relocate CSS Loader Container

Can someone help me with adjusting the placement of my container? I'm struggling to maintain the styles while getting rid of the position: absolute; on the .dot class. Every attempt I make is resulting in the dots moving erratically! To clarify, I w ...

What is the best way to align a div in the middle of an input-group div?

When dealing with a nested div, where the parent div is styled with an input-group class, my goal is to have the nested div centered within the available line or on the next free line space. This is the desired layout I want to achieve regardless of the n ...

Setting up pagination for displaying data from a database on the client-side: a step-by-step guide

Greetings to all my fellow programmers on Stack Overflow! I am currently in the process of developing an e-commerce application using JSP. The products for the application are stored in a server-side database (Mysql) within a table named product. The prod ...

Exploring HTML Data with Python String Manipulation

My goal is to use Python to dynamically extract data from an HTML page that is constantly changing. I have identified that the specific data I am interested in is located between a tag that resembles 'abcd>' and another tag. For example: abcd& ...

Storing data efficiently with Angular 2's local storage service

I am attempting to create a ToDoList using localstorage within a service. add.component.ts export class AddComponent implements OnInit { item: Item[]; constructor( private router: Router, private itemService: ItemService) { } ...

Adjusting content alignment for mobile devices and centering on desktop screens

I am currently working on creating a responsive website and I have a specific layout in mind. I want to center some text and an image both vertically and horizontally within a div that has a minimum height, leaving plenty of blank space above and below the ...

Zooming in on the background with an animated effect

I'm experimenting with a zoom in animation on a background image for a brief moment. It seems to work initially but then resets itself. To see an example, I've created a jsfiddle link: https://jsfiddle.net/onlinesolution/tk6rcLdx/ Any idea what ...

Incorporating a static background image slideshow in ASP.NET - a step-by-step guide

I am currently working on my asp.net website and I would like to incorporate an image slideshow as the background of my homepage. This idea was inspired by a site I came across, . I have successfully implemented the slideshow, but now I am wondering if it ...

In Internet Explorer, auto margins in Flexbox do not function properly when using justify-content: center

My table has cells that can contain both icons and text, with the icons appearing to the left of the text. There are different alignment scenarios to consider: Only an icon is present: The icon should be centered Only text is present: The text should be ...

output a string from the write_html function in plotly

I am currently attempting to utilize plotly express to generate a string representation of a div object in HTML for integration with other packages. Although I have been following the documentation (Plotly v5.17.0), it seems that my attempts have not been ...

Closing the modal by simply clicking outside of it's boundaries

Is there a way to close the modal by clicking outside of it using pure JS or AngularJS? I'm struggling to figure out how to implement this functionality. Any assistance would be greatly appreciated. View Fiddle .modalDialog { position: fixed; ...

The offset value was inconsistent in the desktop version of Firefox

Could you take a look at my code on the fiddle link, Here is the code snippet: <body> <div id="content" style="width:400px; height:110px;"> <svg id="circle" height="300" width="300"> <circle cx="150" cy="150" r="40" st ...

Looking to slide a form on top of an image carousel in Bootstrap - any tips?

How can I move this form over the "carousel"? <html> <head> <title>test</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http ...

Can someone explain the functionality of the CSS Selector > * when used inside a Vue.js component?

While exploring the Vuestic admin dashboard tool, I noticed a glitch in the UI where the donut chart appeared larger than its container. I tried to troubleshoot and fix it for submission as a PR, but I encountered an unfamiliar CSS selector > * while de ...

Expand a div without causing any displacement to surrounding elements

If you have 4 colored divs (red, yellow, green, blue), with 2 per row, and need to expand the second (yellow) without creating a gap under the red, check out this solution. The blue will be positioned underneath the expanded yellow. For a live example, vi ...

The properties of JavaFX in the CSS file are not recognized by Eclipse, showing an error message as "unknown property"

After installing Eclipse and downloading the OpenJFX SDK, I encountered an issue where Eclipse marked all -fx- properties in the .css file as warnings with the message "unknown property". Surprisingly, my JavaFX projects still compiled and ran smoothly, ...