The Bootstrap4 HTML page is oversized on mobile devices

Being relatively new to Bootstrap and CSS, I have been rebuilding this site multiple times over the past couple of weeks in an attempt to fix spacing issues. Currently, I am facing a problem where the main section is slightly too wide for mobile screens in the x-dimension and allows scrolling, which is not the desired behavior. Despite trying various configurations, I am unable to identify the source of this right margin. The content fills the screen until scrolling, leaving a noticeable sliver of the background body color visible. Upon debugging, it appears that the margin resides between the body and the main section. Here is what I have tried in my CSS:

html {
  overflow-y: scroll;
  overflow-x: hidden;   // this solves the problem on a small browser window but not on mobile device.
  margin: 0;
  padding: 0;
}

body {
  margin: 0;
  padding: 0;
}

main {
  margin: 0;
  padding: 0;
  background-color: #000; // this is what i was referring to that leaves a white margin after scrolling if this color is in the body, the margin is black.
}

main > .container {
  padding-top: 54px;
}

In my HTML, I have included:

<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

Along with all other necessary Bootstrap and JavaScript elements.

I am using the Django framework, so the HTML is formatted as Django templates. The base template contains the main section with a navbar:

<body>
  <header class="site-header">
    <nav class="navbar navbar-expand-md navbar-dark bg-steel fixed-top">
      <div class="container">
    <!-- # Navbar stuff-->
      </div>
    </nav>
  </header>
  <main role="main" class="container">
    <div class="row justify-content-center">
      <div class="col col-md-10">
        {% if messages %}
          {% for message in messages %}
            <div class="alert alert-{{ message.tags }}">
              {{ message }}
            </div>
          {% endfor %}
        {% endif %}
      </div>
    </div>

    {% block content %}{% endblock content %}
  </main>
  <!-- scripts-->
</body>

The inner template typically begins like this:

<div class="container">
  <div class="row justify-content-center">
    <div class="col col-md-8">

Despite troubleshooting, the issue seems isolated within the base template. I am at a loss and considering a complete rebuild, but wanted to reach out here first!

Answer №1

It is recommended to utilize col-sm-[1 - 12]

Answer №2

Although the previous solution addressed the problem in one case, it was actually caused by my decision to remove the padding from the .container class used on all pages. Reverting to the default bootstrap container resolved the issue, as the columns indeed defaulted for small screen settings as initially believed.

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

Is it possible to utilize jQuery for loading an external PHP file?

Apologies for the simplicity of my question, but I've been struggling to pinpoint the issue. I have a basic HTML form with just one checkbox. My goal is to use jQuery to load an external PHP file onto the same page within the 'content' div i ...

Experience an enhanced replay of canvas drawings with advanced line smoothing technology

Enter your name on the canvas below, and the code will save the drawing coordinates in an array. However, I am having trouble replaying the drawing using these coordinates. It seems to be drawing too quickly! What would be your approach to resolve this is ...

Retrieve information from api and showcase it in html

Recently, I came across an interesting API file that caught my attention: My goal is to extract information from this API and present it on a HTML page in a visually appealing format. Despite scouring various forums, I have yet to find a solution that fi ...

Material User Interface, MUI, Modal, Back to Top Scroll按钮

After spending some time experimenting with scrollTop and the Dialog component (a fullscreen fixed modal) from Material-ui, I found that I couldn't quite get scrollTop to function properly. Whenever I clicked the "go down" button, it would either retu ...

Tips for integrating Rate Yo into the database

I have been attempting to integrate Rate Yo into the database, but I am consistently encountering an error message: Undefined index: rating in C:\xampp\htdocs\bill\bill\add_rate.php on line 57 Below is the code that I have trie ...

What is the best way to set the tab as "active" in the first iteration of a PHP while loop?

When using a while loop to populate tabs with PHP, maintaining only one active tab at a time can be tricky. I have grasped that assigning the 'active' class within the loop causes all tabs to become active. So, how should I modify the script if I ...

Encountering issues with integrating Django URL patterns with Angular routing

Currently, I am working on a project that involves using Django and Angular. I have been attempting to integrate Django's Password-Reset app, which is relatively simple to configure. However, when following the instructions, I encountered a unique iss ...

Unique fluid layout with varied behavior

I am on the hunt for a layout that caught my eye some time ago, but unfortunately I forgot to save it. It featured 3 main columns that cleverly transformed into 2 when resized, causing the 3rd column to shift to the row below. It wasn't your typical l ...

Having issues with column offsetting in Bootstrap v4.0.0-beta

While using Bootstrap 4 Beta (Bootstrap v4.0.0-beta), I encountered an issue with offsetting columns. Previously, I used offset-md-* and it worked fine. However, this feature has been removed in BS4 Beta as per the documentation. The new method suggested i ...

Tips for submitting a specific form

I am in need of submitting a form in a specific format, This is how I want it, as requested by the server to create a user with access: { "archived": false, "client": 1, "first_name": "Foo", "id": 5066549580791808, "inactive": false, ...

Activate the sliding animation for closing the modal window

I have successfully implemented a modal using a combination of html, css, and JavaScript. The code snippets are provided below for reference. One noticeable feature is that the modal window opens with a sliding animation effect from the top. However, I a ...

The alignment of buttons in the div row is not accurate

Here is the code snippet that I am working with: <div class="row"> <div class="col-md-2"> <div class="dropdown"> <button type="button" class="btn btn-bee-space-blue dropdown-toggle buttonWidth" data-toggle="drop down" aria ...

Is there a way I can position my privacy alert so that it appears in front of all DIVs, RevSlider,

Have you had a chance to visit my website at ? I recently added a privacy alert in compliance with the new EU Regulation. However, I'm facing an issue where the alert is overlapping with some of my website components such as other DIVs and Revolution ...

What is the most efficient way to combine a parameter string within a JavaScript function and append it to an HTML string?

Welcome to my HTML code snippet! <div id="content"></div> Afterwards, I add an input to #content: $( document ).ready(function() { // Handler for .ready() called. var parameter = "<p>Hello</p>"; $("#content").appe ...

Numerous JavaScript functions seamlessly integrated into HTML

I'm currently working on incorporating two sliders into my HTML code and utilizing JavaScript functions to update the values indicated by those sliders. I am facing an issue with organizing the code for the output of each slider, possibly due to how t ...

The timeline aesthetic can be achieved solely through the use of HTML, CSS, and potentially some Bootstrap functionalities

https://i.sstatic.net/EsDAE.png Up to this point, I've only been able to make it this far. I'm using a sample code from w3school https://i.sstatic.net/G1FcQ.png I've been attempting to get the year in the same position as in the image, bu ...

Make sure to employ Bootstrap's justify-content-between and stack-to-horizontal col correctly

I am currently working on a responsive form that contains 1 label, 1 input field, and 5 buttons. Both the buttons and the input field are located under col-8. The positioning I aim for the buttons is as follows: They should start below and align with ...

What is the best way to incorporate font-awesome icons into a Rails view?

I'm struggling to incorporate font-awesome icons in my Rails view. I had a static standalone HTML code snippet that I added into the Rails view: <span class="icon-white"> <a href="https://twitter.com/xyz"> <i class="icon icon-tw ...

Pressing JavaScript buttons to trigger another button

I am looking to develop a script that generates a button which then creates another button. The subsequent button will be assigned an id attribute by incrementing from 1 to infinity. This feature should apply to all buttons (original button and the newly ...

The CSS isn't functioning correctly in the HTML file as it is in the CSS file

When I added this code directly to my html file, it worked perfectly: <style type="text/css" media="screen"> #headerimg { display: block; background-image: url('/Content/images/epp/ebweblogo1.gif'); background- ...