Main-container div in Bootstrap CSS sliding beneath the side navigation bar

I recently acquired a Bootstrap 4 theme and have been modifying some files to make it compatible with Flask. However, I'm facing an issue where the "main-container" div falls below the nav bar when I resize the page to full desktop browser size. In the original Bootstrap file, the index.html had the nav bar and page content on a single page. For Flask, I split this into three files: layout.html, index.html, and _navbar.html.

My goal is to have the content on the right side of the nav bar when stretched to full desktop size, but I'm struggling to identify what needs to be changed in order to achieve this.

layout.html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Pipeline Project Management Bootstrap Theme</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="A project management Bootstrap theme by Medium Rare">
        <link href="static/img/favicon.ico" rel="icon" type="image/x-icon">
        <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css?family=Gothic+A1" rel="stylesheet">
        <link href="static/css/theme.css" rel="stylesheet" type="text/css" media="all" />
    </head>

    <body>

       {%include 'includes/_navbar.html'%}

            {%block body%}


            {%endblock%}

        <script src="static/js/jquery.min.js"></script>
        <script src="static/js/autosize.min.js"></script>
        <script src="static/js/popper.min.js"></script>
        <script src="static/js/prism.js"></script>
        <script src="static/js/draggable.bundle.legacy.js"></script>
        <script src="static/js/swap-animation.js"></script>
        <script src="static/js/dropzone.min.js"></script>
        <script src="static/js/list.min.js"></script>
        <script src="static/js/bootstrap.js"></script>
        <script src="static/js/theme.js"></script>

    </body>

    <footer>
        <p><center><small><small>&copy; ME | &copy;ME </small></small></center></p>
    </footer>
</html>

index.html

{%extends 'layout.html'%}

{%block body%}

<div class="main-container">
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-lg-11 col-xl-9">
                <section class="py-4 py-lg-5">
                    ...
                </section>
                <section class="py-4 py-lg-5">
                    ...
                </section>
            </div>
        </div>
    </div>
</div>

{%endblock%}

_navbar.html

[![<div class="layout layout-nav-side">
    <div class="navbar navbar-expand-lg bg-dark navbar-dark sticky-top">
        ...
    </div>
</div>

https://i.sstatic.net/HwHCt.png

Answer №1

Divs are naturally set to display: block, causing them to stack on top of each other.

To position them correctly, you have a couple of options:

  • Enclose them in a container div and utilize flexbox for positioning (such as Bootstrap rows and columns),
  • Utilize floats (like the Bootstrap float classes).

Here's an example demonstrating the use of floats to position divs:

.container {
  width: 500px;
}
.nav {
  float: left;
  width: 30%;
  height: 200px;
  background-color: red;
}

.content {
  float: left; 
  width: 70%;
  height: 200px;
  background-color: blue;
}

.clear {
  clear: both;
}
<div class="container">
  <div class="nav">
  </div>
  <div class="content">
  </div>
  <div class="clear">
  </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

Ways to display notifications when the user is not actively browsing the website?

How can websites display notifications even when the user is not actively on the site? Take Facebook messenger, for instance. Even with the page closed, notifications still pop up. The same goes for Twitter, which also sends push notifications. I ...

Modify the static navigation menu to a dynamic menu in Wordpress

Currently, I am attempting to transform my static navigation menu into a dynamic WordPress navigation menu. This is the code that I currently have: <nav> <ul id="menu"> <?php $pages = array( 'in ...

menu featuring a creative favicon and an accompanying label

I am aiming to replicate this menu design: It consists of a flavicon with a label below it. Menu I attempted to create it in two different ways, but both attempts were unsuccessful. Using Bootstrap groups. <link rel="stylesheet" href="https://u ...

Is there a method to view text options that are too long within a fixed width <select multiple> HTML box?

Here is the code I am working with: <div id='div2' style='height: 430px; width: 350px; overflow:auto;'> <select multiple id="id" size="28" style="FONT-SIZE: 12px; FONT-FAMILY: Arial; width: 100%"> It's a challenge bec ...

CSS animation for dynamic zoom in and out effect inspired by Apple's slideshow feature

I really love the smooth auto zoom in and out effect on this website: , especially for the banner images at the top. I tried to recreate it by inspecting the developer tools in my browser, but I'm having trouble implementing it as some properties are ...

Arrange the HTML DOM elements in the order of their appearance in a list

Is it possible to rearrange the order of <div> and its elements based on database information? For example, consider the following HTML structure: <div id="container"> <div id="A"> Form elements for A</div> <div id="B"& ...

Passing a variable from a jQuery function to a submitted form: the ultimate guide

I stumbled upon this code snippet online and it's exactly what I needed to learn from as a beginner using jQuery. However, I have a question about transferring or passing the value of counter that was used in the jQuery script within the HTML head tag ...

Is it possible to modify the CSS styles for a specific portion of an input value?

Currently, I am in the process of developing a form using React.js where a specific input must match the label written above it. Here is an example: https://i.stack.imgur.com/S2wOV.png If there happens to be a typo, the text should turn red like this: h ...

Having trouble getting Chrome to load my JavaScript script file

Setting up a server on my computer was a simple task, but now I am facing an issue with loading a script file in my HTML. var express=require('express'); var app=express(); app.listen(3000); app.use(express.static('/scripts' ...

Retrieve the input name array key value using jQuery from the adjacent TD

It's a tough one to summarize in the title, but here is the code snippet that explains it: <tr class=""> <td> <input value="9" name="set[122][order]"></input> <input class="set-id ...

PHP file unable to access Bootstrap file

I have my bootstrap css file stored in the following directory: C:\Users\SCEA\Downloads\bootstrap-3.3.7\css When linking this css file to my php file, I used the absolute path: <link href="C:\Users\SCEA\Downl ...

Adjust Fabric js Canvas Size to Fill Entire Screen

Currently, I am working with version 4.3.1 of the Fabric js library and my goal is to adjust the canvas area to fit its parent div #contCanvasLogo. I have tried multiple approaches without success as the canvas continues to resize on its own. Below is the ...

Adjust the form input box height to a different size

Is there a way to adjust the height of the form input box so that the text is positioned close to the top and bottom borders of the box? I attempted to modify the CSS but was unsuccessful. Any suggestions for a Bootstrap CSS solution would be greatly appre ...

Why is my Bootstrap 4 Modal not appearing? Just a black screen with no modal?

https://jsfiddle.net/0z9mbp4r/ <tr> <td>11</td> <td><a data-toggle="modal" data-target="modal10">Miscellaneous Title</a></td> <td><p>C+</p></td> <td><i class="fa fa-sta ...

Setting limits to disable or remove specific times from the time picker input box in Angular

I'm having trouble with a time input box. <input type="time" min="09:00" max="18:00" \> Even though I have set the min and max attributes to values of 09:00 and 18:00 respectively, it doesn't seem to be working properly. I want to ...

Will the identifier "id" be considered unique if the element with the matching id has its display property set to "none"?

Imagine you have a DIV element in your document with the id "row". Now, if you add another DIV with the same id and change the display property of the first DIV to "none", does the id of the second DIV become unique? ...

"Create a unique visual layout with CSS using a four-grid

When utilizing four div grids and increasing the content size of table 2, it causes table 3 to align with table 4, creating a large gap between tables 1 and 3. Is there a way to adjust the responsive content sizing for tables 1, 3, 5... and 2, 4, 6... in o ...

Reading JavaScript files using the HTML 5 File Reader

Currently, I am working on a feature that allows users to drag and drop a folder containing JavaScript files into an HTML5 page. Here is the code snippet for my implementation: $scope.files = []; //Establish dropzone var dropbox; dropbox = document.getEle ...

The AJAX request to the URL is failing

Creating a webpage with the ability to control an IP camera's movements such as moving up and down or zooming in and out involves calling specific URLs. While trying to implement this feature asynchronously, I encountered issues using AJAX which did n ...

Error message: The Modelviewer is unable to load the local file, displaying the message "Unauthorized to access local resource."

For my WebAR project, I am utilizing Google's ModelViewer. In my vue.js project, I have a component that loads the model using the <model-viewer> attribute. My goal is to set the src attribute of the model-viewer to the absolute path of the .gl ...