The Bootstrap theme showcases a narrower layout than its parent container

I'm struggling with managing the width of the bootstrap container and row.

Inside the row, I've placed all the content, but for some reason, the sizes are showing differently on jsfiddle and the image preview.

<!DOCTYPE html>
<html lang="cs">
    <head>
        <title>xGhost.cz | Československý Gamehosting.</title>
        <!-- meta data -->
        <meta name="author" content="Jan Dvořák">
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- styles -->
        <link rel="stylesheet" href="css/style.css">
        <!-- BOOTSTRAP START -->
        <link href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
        <script src="https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.bundle.min.js" integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ" crossorigin="anonymous"></script>
        <!-- BOOTSTRAP END -->      
    </head>
    <body>
        <div class="container-lg">
            <div class="row">
                <div class="row">
                    <div class="col-lg-1">
                        <img src="img/xGhost.svg" alt="" style="width: 300px; height: auto;"/>
                    </div>
                </div>
                <nav class="navbar navbar-expand-md navbar-dark bg-dark mt-2">
                    <a class="navbar-brand" href="#" style="font-style: italic;">xGhost.cz</a>
                    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
                        <span class="navbar-toggler-icon"></span>
                    </button>

                    <div class="collapse navbar-collapse" id="navbarTogglerDemo02">
                        <ul class="navbar-nav ms-auto">
                            <li class="nav-item"><a class="nav-link active" aria-current="page" href="#">Úvod</a></li>
                            <li class="nav-item"><a class="nav-link" href="#">Ceník</a></li>
                            <li class="nav-item"><a class="nav-link" href="#">Objednávka</a></li>
                            <li class="nav-item"><a class="nav-link" href="#">Příručka</a></li>
                            <li class="nav-item"><a class="nav-link" href="#">Servery</a></li>
                            <li class="nav-item"><a class="nav-link" href="#">Technika</a></li>
                            <li class="nav-item"><a class="nav-link" href="#">Kontakt</a></li>
                        </ul>
                    </div>
                </nav>
                <div class="row gx-2 mt-3">
                    <div class="col-md-8">
                        <div class="box">
                            <div class="box-heading">Novinky & Blog</div>
                        </div>
                    </div>
                    
                    <div class="col-md-4">
                        <div class="box">
                            <div class="box-heading">Přihlášení</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>

CSS:

body {
    background: url(../img/bg.jpg) no-repeat center center fixed; 
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

.navbar {
    text-align: center;
}

.nav-link:hover {
    color: rgba(39, 174, 96, 1.0) !important;
}

.box {
    width: 100%;
    height: auto;
}
.box-heading {
    background: #212529 !important;
    color: #fff;
    text-align: center;
    padding: 7px;
    width: 100%;
}

JSFiddle: https://jsfiddle.net/1c9w3taq/

Check Image Preview Here

The image clearly shows the misalignment in the content. The logo column width is slightly off on the right, and the two boxes at the bottom are not aligned with the sides of the parent container.

Answer №1

This particular issue stems from the following div element.

<div class="col-md-8">

Additionally, there is also a

<div class="col-md-4">

While both add up to 12, they come with a margin.

To resolve this issue, you can introduce a class like the following.

.nomargin{
margin: 0px !important;
}

Then, apply this class as shown below.

By doing so, you eliminate the default margin set by Bootstrap.

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

How to Preserve Image Aspect Ratio within a Div Using the 'Overflow: Hidden' CSS Property

I am in the process of creating a profile page that takes inspiration from Facebook's layout design, particularly focusing on the banner and profile image combination. While my implementation looks good on desktop screens, I am facing challenges when ...

Transforming traditional HTML table layout to modern div structure

We are currently in the process of transitioning old pages from our previous website structure, which used tables, to our new layout based on DIVs. Our website is structured using a PHP include system with separate components for the header, body, and foot ...

A unique way to present data: An HTML table featuring four fixed columns with horizontal scrolling

I've been having difficulty creating a table with fixed first four columns while allowing the rest to scroll horizontally. I came across this example first column fixed Although the example has the first column fixed, I'm struggling to extend it ...

What is the best way to toggle the active class on a ul list?

After clicking, the active class remains on the original "li" instead of changing as it should. I've tried modifying the code but haven't been able to find a solution. Can someone please review what I might have missed? It seems like there's ...

Troubles with Placing Image on WordPress

Working on a Wordpress component for a website where I placed a "SOLD OUT" image over text. However, the issue arises when viewing the site on mobile devices, as the images are smaller and not in their correct positions due to using absolute positioning. ...

Ways to switch out event listener when button is deactivated

I find myself in a situation where I need to switch all unauthorized controls on my UI from a hidden state to a disabled state. Additionally, I want to add a tooltip with unauthorized text and have the control display this text when clicked. While I am ab ...

There seems to be an issue with the main.scss file in your SCSS assets folder: Unable to locate or read the file being

I've been struggling to publish my Jekyll and Bootstrap website on GitHub, but I keep encountering an error message: Your SCSS file assets/main.scss has an error on line 47: File to import not found or unreadable: assets/css/minima/base. Load paths: ...

The Bootstrap table fails to display any data retrieved from the server

I recently attempted to implement pagination using this resource: After setting up the HTML table on my page and confirming that the server-side code is functioning properly by checking the Network tab in the F12 tools, I ran into an issue. The data retur ...

Prevent the onClick function of the outer div from being triggered by clicking on the inner div

Similar Question: Stop parent container click event from firing when hyperlink clicked My issue is <div onClick="someJScode();"> ... <div></div> ... </div> I need to prevent someJScode() from executing when the inner di ...

Tips for showcasing div content on a separate line rather than inline within a collapsible <a> tag

I am currently working on integrating a sidebar using bootstrap 5. When I click on the user initials, I want something like this to happen (collapse): https://i.sstatic.net/ejbhD.png However, the result I'm getting is different: https://i.sstatic. ...

Elements powered by jQuery failing to load upon dynamic webpage(s) loading via ajax

Dynamic loading of jQuery elements, such as Ibuttons, seems to be causing issues when implemented with an ajax dynamic content loader. The entirety of my website is rendered through Ajax just like this: <html> <header> {jQuery} </header> ...

Steps for generating a dropdown menu using API JSON information

I'm new to using Webapi with AngularJS. I have a URL that returns data in JSON format, and I want to extract only the employee names from the data and display them in a dropdown list using AngularJS. Any assistance would be greatly appreciated. ...

Plotly Express Unleashes the Power of Subplots

After spending countless hours scouring the internet, I am feeling utterly frustrated and perplexed about how to deal with subplots using plotly express in Python. The concept is to create a line plot alongside a scatter plot and another line plot, where ...

Styling in CSS to ensure scrollbar is constantly displayed without narrowing the container's width

Is it possible to have a vertically scrollable div with an always visible scrollbar without the scrollbar affecting the width of the elements inside? I attempted some CSS modifications, but the scrollbar still reduced the available width of the div. Is th ...

Exploring HTML attributes with Nokogiri

Below is the code snippet that I've been working with: location = block.xpath("*/img") puts location Upon execution, the code provides the following output: <img src="/images/p.gif" height="1" width="0"> My objective is to extract the widt ...

The .AppendChild() method does not appear to be working as expected following the completion of

Encountering a peculiar problem here. The scripts run smoothly, but the content doesn't display on screen until I "inspect element" and then close the inspector window or zoom in/out. It's not an issue with the "display" CSS property because even ...

Unusual behavior observed while looping through an HTMLCollection returned by the getElementsByClassName method

After spending some time debugging, I discovered an issue with my function that changes the class of elements to modify their properties. Surprisingly, only specific elements were being affected by this change. It took me a while to troubleshoot and resolv ...

Instructions for submitting a form using Xcode

How can I automate the submission of a form in a webview? Here is my code: #import <Cocoa/Cocoa.h> #import <WebKit/WebKit.h> #import <WebKit/WebResourceLoadDelegate.h> @interface AppDelegate : NSObject <NSApplicationDelegate> @pro ...

I'm currently attempting to determine the total cost of a series of operations, however, I am not receiving any results

Here is the code snippet from my HTML file: <tr> <td><input id="z1" type="number" oninput="calculateSubTotal()"> </td> <td>Shirts - WASH - Qty 1 to 4</td> <td>2.50 ea</td> ...

Customize Bootstrap Navbar Dropdown Menu to Align on the Right

I am encountering an issue where the dropdown menu appears at the bottom-right of the bell icon when I click on it (see image link below). However, I would like the dropdown menu to appear at the bottom-left instead. How can I achieve this? https://i.ssta ...