The DIV element is failing to fill the entire screen's width

I am completely new to web development and currently working on creating my very first website. I've managed to set up the layout, but I'm facing an issue when trying to optimize it for mobile devices. Specifically, some of my divs (particularly the police-div) are not expanding to the full width of the screen, and I'm uncertain as to why this is happening. I even tried removing the background image, but the problem persists.

Any assistance or guidance on this matter would be greatly appreciated!

Here is the problem I am encountering: https://gyazo.com/593e152db8e3a15cd7bedcfb30b8fe08. This is the desired look I am aiming for: https://gyazo.com/ffdcb59173137df53ba18f466411bac8

   /*Main*/
   @import url('https://fonts.googleapis.com/css2?family=Lato&display=swap');

   html, body
   {
       width: 100%;
       height: 100%;
       margin: 0px;
       padding: 0px;
       overflow-x: hidden; 
       background-color: white;
       font-family: 'Poppins', sans-serif;
      }

 /*NavBar ;*/

   #logo-space{
     width: auto;
     height: auto;
     background-color: #0f2471;

   }

   #logo-space img{
     width: 5010;
     height: auto;
     position: relative;
     left: 2.5rem;
   }

   #fms-btn{
      width: 120px;
      position: relative;
      top: 1rem;
      right: 2rem;
      height: 60px;
      font-size: 1rem;
      justify-content: center;

      text-decoration: none !important; 
      background-color: #030b29;
      color: white;
    }

   .nav-bar{
       background-color: #16377e;
       position: relative;
   }
 
   #navbar-space .nav-link{
     position: relative;
     left: 4rem;
   }


   #home-img{
    /* to remove space between images, because car image has this wave and page background would be visable */
    margin-bottom: -86px;
    padding-bottom: 20px;
  }

  #home-img img{
    object-fit: cover;
    width: 100%;
    height: 50vh;
  }

  #about-us{
    background-color: white;
    background-position: center;
    background-size: cover;
    z-index: 2;
    /* probably padding needed */
    color: #030b29;
    height: 50vh;
  }

  #about-title{
  font-weight: bold;
  font-size: 45px;
  color: #030b29;
  }

  ...

  @media (max-width: 400px) { 
    ...
  }
<!DOCTYPE html>
<html>
  <!--When Site is finished, check all compats-->
  <head>
    ...
  </head>

  <body>
    
  <body style="margin: 0;">

        <!--Logo Space-->
        ...
...
  
  </body>

</html>

Answer №1

Here is a CSS snippet for the .row.justify-content-center class that you might find useful.

/*Main*/

@import url('https://fonts.googleapis.com/css2?family=Lato&display=swap');
html,
body {
  width: 100%;
  height: 100%;
  margin: 0px;
  padding: 0px;
  overflow-x: hidden;
  background-color: white;
  font-family: 'Poppins', sans-serif;
}


/* Added */

.row.justify-content-center {
  flex-direction: column;
  place-items: center;
}

/* Rest of the CSS code */

<!DOCTYPE html>
<html>
<!--When Site is finished, check all compats-->

<head>
  <title>Divisions - South Yorkshire RPC</title>
  <!--CSS-->
  <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8be9e4e4fff8fff9eafbcbbea5b9a5bba6e9eeffeaba">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
  <!--Font Awesome-->
  <script src="https://kit.fontawesome.com/b5212ab333.js" crossorigin="anonymous"></script>
  <!--Index Stylesheet-->
  <link rel="stylesheet" type="text/css" href="css/divstyle.css">
  <!-- JavaScript Bundle with Popper -->
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="adcfc2c2d9ded9dfccdded98839c839f">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-kQtW33rZJAHjgefvhyyzcGF3C5TFyBQBA13V1RKPf4uH+bwyzQxZ6CmMZHmNBEfJ" crossorigin="anonymous"></script>

  <link href="https://fonts.googleapis.com/css?family=Rubik" rel="stylesheet">

  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <style type="text/css"></style>
</head>

<body>

  <body style="margin: 0;">

    <!--Logo Space-->
    <div id="logo-space">
      <div class="row">
        <div class="col">
          <img id="logo" src="img/logo.png" class="image-fluid" alt="">
        </div>

        <button id="fms-btn" type="button" class="btn  mx-4 m-3">
                <span class="text-center" style="text-decoration: none;">Head to FMS</span>
            </button>
      </div>
    </div>

    <!--Nav Bar and other sections-->

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

Triggering blur event manually in Ionic 3

Is there a way to manually trigger the blur event on an ion-input element? The ideal scenario would be with an ionic-native method, but any javascript-based workaround will suffice. My current configuration: Ionic: ionic (Ionic CLI) : 4.0.1 (/User ...

How can components be utilized with v-edit-dialog?

Hey there, I've been exploring the v-edit-dialog component offered by Vuetify and had a query about its implementation. Currently, I'm structuring my v-data-table in a way where I'm importing a component with props into a template slot. The ...

Update the div element without needing to reload the entire page

Is there a way to reload a div tag without refreshing the entire page? I understand this question has been asked before, but I want to make sure I have a clear understanding. <p>click HERE</p> <div class="sample"> <?php functi ...

What is the reason for Rich file manager to include filemanager.config.json instead of simply adding an image to the text

I have integrated Rich File Manager with Laravel 5.3.20 using the default configuration provided below: Javascript <script> CKEDITOR.replace( 'textarea', { filebrowserBrowseUrl: '{!! url('gallery/index.html& ...

JavaScript: a single function and two calls to Document.getElementById() results in both returning "undefined"

Within my JavaScript file, I have a function that utilizes two variables: choice and courseChosen. The latter variable must be converted into an object first. In the HTML, the tags courseName and courseInfo are used for choice and courseChosen respectively ...

Unable to modify the border color of the outline in MUI text fields

I am currently working on a React project using MUI and styled-components, but I am facing an issue with changing the outline border color of a textfield. Despite reading the documentation and attempting to overwrite the class names of the component, it do ...

Embracing the Power of Sass

I have recently revamped my portfolio website on Github Pages and now I am looking to integrate Sass for my upcoming Portfolio 2.0 project. Although I have worked with Sass before, setting it up from scratch is new to me. Currently, I have installed Sass ...

Inserting multiple values into my PDO database

I am facing an issue with my code that I need help with. I am trying to include more data than just my :SteamID in my database. This function/PDO is currently executing every time someone visits my site. Working code: /*Check possible existing data*/ $odb ...

What is the method for incorporating text below font icons?

Having a bit of trouble here with my code snippet featuring 'font awesome' icons in circles. I'm looking to add text beneath each icon, but the alignment within the circle is proving to be a challenge. Check out the code in this link to see ...

What might be the reason behind the failure to implement my color class on the text within the <p> element?

I'm looking to streamline my stylesheet to easily change the color of different text elements. I've created a list of general colors that can be applied using classes, like (class="blue") . Here are some examples: .dark-grey { color: #232323; } ...

Creating a versatile function to verify the presence of empty values

Looking to validate fields for emptiness in a router, with potential use in other routers as well. How can I create a single function to handle this task? To see how it operates: , Desiring something similar to: , ...

Divide a page into two equal halves

I have been working on the code below. The circular icons function as navigation buttons. The collapsible list is located in the second div. My goal is to align the list to the right side of the navigation buttons. Despite trying to wrap the divs and us ...

Sending a JavaScript variable to PHP and retrieving the PHP result back into a JavaScript variable

I am looking to transfer a JavaScript variable to a PHP file using AJAX, and then retrieve the PHP file's output back into a JavaScript variable. For sending the JavaScript variable to the PHP file, I found a method that suggests using ajax to assign ...

What is the process for embedding a 3D model using three.js into a specific div on a webpage?

Lately, I've been struggling with a persistent issue. I can't seem to figure out how to integrate my three.js scene into a div on my website. Despite watching numerous YouTube videos and reading countless articles on the topic, I still haven&apos ...

Slideshow: I hope the Radio Button triggers the appearance of the next item in the rotation

I need to implement a carousel that displays the next item (Id="item2") when a specific radio button (Id="item1") is selected by default and another radio button (Id="item2") is pressed. Ideally, I would like to achieve this ...

Searching for an object in a more efficient manner

At times, I often find myself needing to locate a specific object within an array of objects where the key I am searching for matches a particular value. For instance: var cars = [ { id:23, make:'honda', color: 'green' }, { id ...

Leverage the power of AJAX to fetch and display controller action results on the current

this is my code of the view I've set up a dropdown menu with options that have values like /ControllerName/ActionName. Upon clicking one of the dropdown values, it redirects me to another page with the selected ControllerName and ActionName. However ...

Creating a Slider with a Multitude of Images

I am working on a project to develop a gallery that pulls images from a JSON source. I have successfully implemented infinite scrolling to display the images on the first page. However, I am now facing a challenge when it comes to showing the selected imag ...

"I seem to be unable to retrieve all the data points for the X and Y axes on my nvd3 graph. Could there be some options that I am

https://i.sstatic.net/ITbJm.png I am encountering difficulty in obtaining all the X and Y intersection points on the axis as shown in the graph image. Additionally, I would like to emphasize the intersection points with a dark circle. Any assistance in re ...

Filling in a text field with the text content (rather than the value) from a dropdown menu

Presently, I have the select box with the id "title" populating a text field with the id "costcenter". The current code works perfectly fine when using the VALUE of the select box to trigger the population of the cost center field. However, my requirement ...