Position the sidebar next to the dashboard content

Objective:
Move the sidebar class to be positioned next to the dashboard content.

Issue:
The Sidebar is currently overlapping with the dashboard instead of being positioned beside it.
What class should replace 'col-sm-2'? ()

jsbin:
https://jsbin.com/xenuwuvisu/edit?html,output

Thank you!

/*
 * Global add-ons
 */

.sub-header {
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

/*
 * Top navigation
 * Hide default border to remove 1px line.
 */
.navbar-fixed-top {
  border: 0;
}

/*
 * Sidebar
 */

/* Hide for mobile, show later */
.sidebar {
  display: none;
}
@media (min-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    display: block;
    padding: 20px;
    overflow-x: hidden;
    overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
    background-color: #f5f5f5;
    border-right: 1px solid #eee;
  }
}

/* Sidebar navigation */
.nav-sidebar {
  margin-right: -21px; /* 20px padding + 1px border */
  margin-bottom: 20px;
  margin-left: -20px;
}
.nav-sidebar > li > a {
  padding-right: 20px;
  padding-left: 20px;
}
.nav-sidebar > .active > a,
.nav-sidebar > .active > a:hover,
.nav-sidebar > .active > a:focus {
  color: #fff;
  background-color: #428bca;
}


/*
 * Main content
 */

.main {
  padding: 20px;
}
@media (min-width: 768px) {
  .main {
    padding-right: 40px;
    padding-left: 40px;
  }
}
.main .page-header {
  margin-top: 0;
}


/*
 * Placeholder dashboard ideas
 */

.placeholders {
  margin-bottom: 30px;
  text-align: center;
}
.placeholders h4 {
  margin-bottom: 0;
}
.placeholder {
  margin-bottom: 20px;
}
.placeholder img {
  display: inline-block;
  border-radius: 50%;
}
<!DOCTYPE html>
<!-- saved from url=(0053)https://getbootstrap.com/docs/3.4/examples/dashboard/ -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Dashboard Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  </head>





  <body>

    <div class="container-fluid">
      <div class="row">
        <div class="col-sm-2 sidebar">
          <ul class="nav nav-sidebar">
            <li class="active"><a href="https://getbootstrap.com/docs/3.4/examples/dashboard/#">Overview <span class="sr-only">(current)</span></a></li>
            <li><a href="https://getbootstrap.com/docs/3.4/examples/dashboard/#">Reports</a></li>
            <li><a href="https://getbootstrap.com/docs/3.4/examples/dashboard/#">Analytics</a></li>
            <li><a href="https://getbootstrap.com/docs/3.4/examples/dashboard/#">Export</a></li>
          </ul>
          ...
      </div>
    ...

      
 
</body>
</html>

Answer №1

The content in the sidebar remains 'half useless' due to having position:fixed set, which means it occupies space but is not factored into the layout calculation by other elements.

To correct this issue, make sure to use the proper className when adding an offset. Instead of using col-md-offset-2, it should be offset-md-2.

You can refer to the solution with offset in the provided example or visit jsbin for more details.

Answer №2

Eliminate the fixed position setting in the sidebar 

Alternatively, assign a width to the sidebar with a fixed position and use that same width as padding-left for the dashboard (along with removing row, col-sm-2, and col-sm-9)

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

Experiencing a horizontal scroll while shifting the elements despite no visible overflow

While working on the contact section of my website, I encountered an issue. Every time I adjust the position of the textboxes and labels by 15em within the wrapper, a horizontal scroll appears. How can I move these elements without triggering the scroll ba ...

The innovative technique of using pure CSS to secure the bottom edge of a div to the viewport

Is there a way to keep two container divs positioned x pixels from the bottom of the viewport without using position absolute|fixed? I want them to remain as position: relative for proper DOM flow. Searching for a CSS-only solution that works in IE7+. Mos ...

The Bootstrap 4 navigation bar fails to be responsive and remains open despite attempts at styling

Having trouble with my navbar functionality... After applying CSS styling, it loses responsiveness and remains open on smaller screens. Here is the code snippet. HTML: <nav class="navbar navbar-expand-sm navbar-dark bg-dark" id="big-bar"> ...

In IE11, the property of table.rows.length is not functioning as expected

In my HTML page, I have the following script: var table = document.getElementById(tableID); var rowCount = table.rows.length; While this script works fine in IE8, in IE11 it does not return the exact row count. Instead, it only returns "0" when the actua ...

Troubleshooting CSS Carousel Navigation Problems

{% extends 'shop/basic.html' %} {% load static %} {% block css %} .col-md-3 { display: inline-block; margin-left:-4px; } .carousel-indicators .active { background-color: blue; } .col-md-3 img{ width: 227px; ...

Align Bootstrap list items vertically

I'm facing a challenge with aligning the yellow list item blocks vertically in my design. The issue arises because the black dog item is not aligning properly due to its image being shorter than the other two blocks. I've been struggling to find ...

Exploring Selenium: Clicking on Auto-Complete Suggestions using Python

Attempting to interact with an auto-complete search bar on the site in order to search for results. Wanting to click on the drop-down element that appears after entering a city name to perform a full city name search and obtain results. Below is the cod ...

What causes the discrepancy in checkbox size between Chrome and Edge browsers?

After creating a table with striped rows using bootstrap 4, I noticed that one of the columns contained HTML checkboxes. Check out the jsfiddle for more details. Upon viewing the table in Google Chrome, I noticed that the default checkboxes appear smalle ...

Dompdf is unable to process data exceeding two pages

Having 85 rows in a table with dompdf is functioning properly, but when exceeding 85 rows, they are not displaying on the 3rd page; instead, they are overlapping on the 2nd page. Incorporating dompdf with codeigniter, I've attempted removing all styl ...

The alarm feature is malfunctioning

I have been struggling with a simple alarm application that I created using jQuery and Javascript. The issue lies in the alarm functionality not working as expected. Below is the relevant code snippet: var today = new Date(); var h = today.getHours(); var ...

Instant data entry upon clicking

In an attempt to automate input based on image pairs, I encountered a challenge. On one side, there are two images that need to be matched with input fields, and on the other side, there are corresponding letters for each image to fill in the inputs upon c ...

Issue with rendering buttons and images with incorrect width and height in Safari

I'm completely lost here... My React project is using reactstrap and Bootstrap. It's functioning perfectly in Chrome, but in Safari, the images aren't loading and the buttons are displaying at half their intended height. I tried switching t ...

Altering custom fields in WordPress based on a specified timeline

Just diving into the world of Wordpress and running into a slight dilemma. I have an image that needs its links changed at specific times throughout the day For example, this image on the website should redirect users to abc.com from 8AM to 12PM when clic ...

Activate the saturation toggle when a key is pressed in JavaScript

I am trying to modify a script that currently toggles the value of a variable when a key is pressed and then lifted. Instead of changing the variable value, I would like to adjust the saturation of the screen based on key presses and releases. How can I ac ...

Navigate through the items in my subnavbar by scrolling the content

HTML Code <div id="subnavigation"> <?php $verbindung = mysql_connect("host", "user" , "pw") or die("Verbindung zur Datenbank konnte nicht hergestellt werden"); mysql_select_db("db") or die ("Datenbank konnte nicht ausgewählt w ...

Can you guide me on implementing a transition animation through class toggling?

I am facing an issue where certain elements need to be highlighted or unhighlighted conditionally. To achieve this, I have assigned a class called highlight to the elements that require highlighting with a transition animation. The challenge arises when t ...

After incorporating some movement effects into my menu, suddenly none of the buttons were responding

While working on my website and trying to add a close menu button, I encountered an issue where all the menu buttons stopped functioning. Here is the HTML code snippet: <div id="openMenuButton"> <span style= "font-size:30px;cu ...

Attempting to implement a feature that will enable a blank row at the end of an input table with the help of

I'm currently working on a form that allows users to click a button to add a blank row to the bottom of a table. The issue I'm facing is that when I click the button, it redirects back to my index.php page instead of simply adding the row to the ...

The text in Bootstrap overflows the card boundaries

I'm facing an issue with a Bootstrap card where the text is overflowing outside of the card box. Here is the code snippet I'm currently using: <div class="card"> <div class="card-text"> <div class="card-block"> ...

The mui table does not adjust to different screen sizes

Currently, I am using the Material-UI table, but it is not responsive. I am looking to set the width in percentages for better adaptability. Below are screenshots from two different screens showcasing the output: https://i.sstatic.net/lxA3u.png https:// ...