I'm interested in creating a unique sidebar layout with Bootstrap 5 - how can

I'm struggling with creating a sidebar for my application and need guidance on using col to organize content into left, right, and center.

Here is my navbar:

<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
    <a class="navbar-brand" href="{% url 'register' %}"><h2>Borinati</h2></a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav ms-auto mb-2 mb-lg-0">
            <li class="nav-item"><a class="nav-link active" href="{% url 'login' %}">Login</a></li>
            <li class="nav-item"><a class="nav-link active" aria-current="page" href="{% url 'register' %}">Sign Up</a></li>
            <li class="nav-item"><a class="nav-link active" href="{% url 'FeedBack' %}">About</a></li>                      
        </ul>
    </div>
</div>

The following content should be aligned to the left:

<a href="">Home</a>
<a href="">Contact Us</a>
<a href="">Companies</a>
<a href="">Products</a>
<a href="">Our Partner</a>
<a href="&">Our Sponsor</a>

And this content is intended to be in the center

<div class="container">
    <div class="row justify-content-center">
      <form action="" method="GET">
        <input placeholder="Search By Category" type="text" class="form-control" name="q">
    </form>
   </div>
  </div> 
  <br>
    
<div class="container">
    <div class="row justify-content-center">
        {% for question in news reversed %}
        <div class="col-md-4">
            <div class="card my-3">
                <div class="card-body">
                    <a href="{% url 'view-News' news.slug %}" style="text-decoration: none;">
                    {{news.title}}
                    </a><br>
                    <br>
                    <a href="{% url 'Public_Profile' news.user.profile.slug %}">
                        {{news.user.username}}
                    </a>
                    <br>
                    <p class="btn btn-primary disabled btn-sm">{{news.category}}</p>                            
                </div>
            </div>
        </div>
        {%endfor%}
    </div>
</div>

Answer №1

This example is almost official, taken from here. I could simply copy and paste it, but I recommend trying it out for yourself.

I even inserted your HTML into the example to see how it looks.

/*!
 * Start Bootstrap - Simple Sidebar v6.0.5 (https://startbootstrap.com/template/simple-sidebar)
 * Copyright 2013-2022 Start Bootstrap
 * Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-simple-sidebar/blob/master/LICENSE)
 */

// 
// Scripts
// 
window.addEventListener('DOMContentLoaded', event => {
  // Toggle the side navigation
  const sidebarToggle = document.body.querySelector('#sidebarToggle');
  if (sidebarToggle) {
    sidebarToggle.addEventListener('click', event => {
      event.preventDefault();
      document.body.classList.toggle('sb-sidenav-toggled');

    })
  };
});
#wrapper {
  overflow-x: hidden;
}

#sidebar-wrapper {
  min-height: 100vh;
  margin-left: -15rem;
  transition: margin 0.25s ease-out;
}

#sidebar-wrapper .sidebar-heading {
  padding: 0.875rem 1.25rem;
  font-size: 1.2rem;
}

#sidebar-wrapper .list-group {
  width: 15rem;
}

#page-content-wrapper {
  min-width: 100vw;
}

body.sb-sidenav-toggled #wrapper #sidebar-wrapper {
  margin-left: 0;
}

@media (min-width: 768px) {
  #sidebar-wrapper {
    margin-left: 0;
  }
  #page-content-wrapper {
    min-width: 0;
    width: 100%;
  }
  body.sb-sidenav-toggled #wrapper #sidebar-wrapper {
    margin-left: -15rem;
  }
}
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dfbdb0b0abacabadbeaf9feaf1edf1eff2bdbaabbeee">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="94f6fbfbe0e7e0e6f5e4d4a1baa6baa4b9f6f1e0f5a5">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet">

<body>


  <div class="d-flex" id="wrapper">
    <!-- Sidebar-->
    <div class="border-end bg-white" id="sidebar-wrapper">
      <div class="sidebar-heading border-bottom bg-light">Start Bootstrap</div>
      <div class="list-group list-group-flush">
        <a class="list-group-item list-group-item-action list-group-item-light p-3" href="#!">Dashboard</a>
        <a class="list-group-item list-group-item-action list-group-item-light p-3" href="#!">Shortcuts</a>
        <a class="list-group-item list-group-item-action list-group-item-light p-3" href="#!">Overview</a>
        <a class="list-group-item list-group-item-action list-group-item-light p-3" href="#!">Events</a>
        <a class="list-group-item list-group-item-action list-group-item-light p-3" href="#!">Profile</a>
        <a class="list-group-item list-group-item-action list-group-item-light p-3" href="#!">Status</a>
      </div>
    </div>
    <!-- Page content wrapper-->
    <div id="page-content-wrapper">



      <!-- Top navigation-->
      <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container-fluid">
          <a class="navbar-brand" href="{% url 'register' %}">
            <h2>Borinati</h2>
          </a>
          <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
          <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav ms-auto mb-2 mb-lg-0">
              <li class="nav-item"><a class="nav-link active" href="{% url 'login' %}">Login</a></li>
              <li class="nav-item"><a class="nav-link active" aria-current="page" href="{% url 'register' %}">Sign Up</a></li>
              <li class="nav-item"><a class="nav-link active" href="{% url 'FeedBack' %}">About</a></li>
            </ul>
          </div>
        </div>
      </nav>


      <!-- Page content-->
      <div class="container-fluid">
   <div class="container">
    <div class="row justify-content-center">
      <form action="" method="GET">
        <input placeholder="Search By Category" type="text" class="form-control" name="q">
    </form>
   </div>
  </div> 
  <br>
    
<div class="container">
    <div class="row justify-content-center">
        {% for question in news reversed %}
        <div class="col-md-4">
            <div class="card my-3">
                <div class="card-body">
                    <a href="{% url 'view-News' news.slug %}" style="text-decoration: none;">
                    {{news.title}}
                    </a><br>
                    <br>
                    <a href="{% url 'Public_Profile' news.user.profile.slug %}">
                        {{news.user.username}}
                    </a>
                    <br>
                    <p class="btn btn-primary disabled btn-sm">{{news.category}}</p>                            
                </div>
            </div>
        </div>
        {%endfor%}
    </div>
</div>
      </div>
    </div>
  </div>
  <!-- Bootstrap core JS-->
</body>

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

Tips for aligning buttons in the center of a card both vertically and horizontally

I am currently utilizing the following bootstrap template to develop a Help Desk Ticket App: After the user logs in on the index page, there are two cards available for the user to choose between heading to the app's dashboard or creating a ticket. I ...

The "add to cart" button is unresponsive

My issue is that the add to cart button on my website is not responding properly. I have implemented JavaScript on the add to cart button, where I have assigned an attribute called data-product with a value of {{product.id}}. var updateBtns = document.g ...

"Transferring a JavaScript variable to Twig: A step-by-step guide for this specific scenario

When it comes to loading a CSS file based on the user's selected theme, I encountered an issue while trying to implement this in my Symfony application using Twig templates. The code worked flawlessly on a simple HTML page, but transferring it to a Tw ...

What is the best way to adjust a <textarea> to fit a multi-column layout?

Here's a cool way to display text in columns: <div class="content-box" style="column-width: 8em"> <p>blah blah...</p> <p>blah blah...</p> <p>blah blah...</p> </div> However, when it comes to the ...

How do I resolve the issue of unable to align the element correctly?

I am struggling to create a hamburger menu icon and align it using flexbox. Unfortunately, the icon is not aligning properly as it is going beyond the menu and the browser screen with an odd top indent. Below is the code I have written: * { margin: 0 ...

Is there a way to format an entire column in bold?

I have a large HTML table that I need to format so that the 16th column stands out by being bold. However, using <colgroup> and <col> doesn't seem to work as intended: <HTML> <BODY> <TABLE BORDER='1'> <colgr ...

Exploring Rails 6: Enhancing Web Design with CSS Image Display

I've been attempting to update my webpage background with an image through CSS, but I'm struggling to reference one of my Rails 6 images in the process. Despite trying options like asset-url and image-url, I haven't been successful. However, ...

The method of utilizing React with Redux to display component properties

I am currently trying to include my common component in my main.js file Successfully implemented this However, when attempting to print my Redux data values in the common component, I created a method called handleClickForRedux to handle this task. Even af ...

Adding a border to dynamically generated content while excluding the outer borders using CSS - an easy guide

My current project involves establishing a grid system that dynamically populates content, resulting in an uncertain number of elements being created. At the moment, each element is placed within a flexbox container with 3 elements per row. If there are mo ...

How to use jQuery to retrieve the second and third elements from a sorted list

Our task is to modify the URL of the image for the second and third elements within an ordered list using jQuery without converting the list to an unordered list. We are looking for a solution to specifically target and modify the class or image of these t ...

Is it possible to extract the CSS path of a web element using Selenium and Python?

I am working with a collection of elements using find_elements_by_css_selector, and my next task is to extract their css locators. I attempted the following approach: foo.get_property('css_selector') However, it seems to be returning None. ...

"Positioning an image at the center with Bootstrap

I've been attempting to center an image on my webpage above the footer, but all my efforts have failed. Here is the HTML code I've been using: <div class="center-block"> <img alt="footer" title="footer" class="image-footer" src="./i ...

Ways to correct inverted text in live syntax highlighting using javascript

My coding script has a highlighting feature for keywords, but unfortunately, it is causing some unwanted effects like reversing and mixing up the text. I am seeking assistance to fix this issue, whether it be by un-reversing the text, moving the cursor to ...

Position the button at the bottom of a div

I am currently utilizing Bootstrap 4.5, however, the following is just a brief demonstration of my desired outcome. Within the dimensions of a fixed-width and height card, I aim to have the content occupy all remaining space while ensuring the button stay ...

What is the best way to eliminate the input border?

click here for image I'm currently working on designing a straightforward login page. However, I've noticed that there are black borders around the input fields. Can anyone help with how to remove these borders? ...

Pressing the button will navigate to page X initially, and then after the countdown finishes, it will

A unique surprise is in store for my wife with this special website. The home page features a countdown to a significant date, and only one button unlocks the gift. I am looking for a way to either keep the button locked until the countdown ends or have it ...

What are the key differences between using role and class selectors in HTML 5 and CSS3 to create two sidebars with three

My decision to eliminate all ids from my CSS and transition to HTML 5 has led me to question the use of roles in markup. In the past, IDs were used to style sidebars individually within a single selector for both. Here is an example: <div id="sidebar" ...

Incorporating text sections into a div container and adjusting the width

Currently facing an issue with the canvas element on my project. <div id="app-container"> <div id="canvas-container"> <div id="canvas"></div> </div> </div> In the CSS stylesheet, the following styles ar ...

Is it feasible in Vue to import an scss file with deep selectors into the scoped styles of a component?

Is it possible to extract a Vue component's scoped SCSS with deep selectors into a separate file and then import it back in? For example: // Main.vue <template> <div id="main"> <h1>Title</h1> <span>Text< ...

Looking for tips on resolving issues with the bootstrap navigation bar?

Check out this code snippet: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport ...