Steps to making an overlapping sidebar with Bootstrap column

I'm trying to set up a sidebar in Bootstrap that overlaps with a column. The goal is for the sidebar to appear when a button is clicked and disappear when the close button x is clicked. Despite using a Bootstrap row and column layout, I encountered issues where the sidebar would end up at the bottom of the page and the button wouldn't respond to clicks.

Here's my HTML code:

<body class="container-fluid">
<div class="row>
 <div class="col-8">...</div> 
 <div class="col-4">...</div> 
 <div id="mySidenav"></div> 
</div>
<span id="pr-btn" style="position:fixed;font-size:30px;cursor:pointer">&#9776; open</span>
</body>. 

My CSS looks like this:

#mySidenav {
 position: absolute; 
 width: 0; 
 right: 0; 
 height: 100%; 
 background-color: #123456
}

This is the JQuery code I'm using:

$("#pr-btn").click(() => {
  let width = $("#mySidenav").css("width");
  if(width == 0) {
    $("#mySidenav").css("width", "33.3%");
  } else {
    $("#mySidenav").css("width", "0");
  }
})

Answer №1

I have found a solution that works for me:

$("#pr-btn").on("click", function(){
  $("#originalColumn").slideUp();
  $("#mySidenav").slideDown();
});

If you have any other suggestions, feel free to share them.

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

What is the process for showing a button once a typewriter animation has completed?

Is there a way to implement a typewriter effect that types out a text line and then displays a button once the animation is complete? Here is the CSS code for the typewriter effect: .welcome-msg { overflow: hidden; /* Ensures the content is not revea ...

Navigating Users to View Their Recently Posted Topic After Clicking Submit in CodeIgniter

Users are able to write articles using a form on my website. Once they submit the form, I want the system to redirect them to view their new post (typically displaying a success message). Controller if ($this->form_validation->run() == TRUE) { ...

Display the actual runtime hyperlink while utilizing the asp tag helper

Whenever I use asp-tag helpers to create a hyperlink, the result is displayed like this: <a asp-page="/demo">Demo</a> The actual html output looks like this: <a href="/test/Demo">Demo</a> However, instead of displaying "Demo" to ...

The angular view is lacking a CSS class

index.html: <div ng-view="myview.html"></div> myview.html: <table class="table table-striped table-hover"> <tr> <td>Name</td> <td>Product</td> </tr> <tr ng-repeat="deal in deals" class="clickableR ...

Display the div with the matching data value when clicked, and conceal all other divs

I need help with a list of items in HTML using UL and LI tags. Each LI item has a specific data attribute value. What I am trying to achieve is that on clicking each LI item, another div with the same data attribute should be displayed while hiding all oth ...

"Is there a way to alter the background color of the second span within a Bootstrap row

I currently have 4 WordPress services in a loop, and I am trying to change the background color of the second service. However, when I try to apply the CSS background property, it ends up affecting all of the services. Here is my template code: <div ...

Tips for preventing multiple clicks when posting AJAX requests in jQuery

Using Django, I was able to create a website and implement a voting page with jQuery AJAX. The code works perfectly fine as shown below: <!doctype html> <html> <head> <script src="jquery-1.10.2.min.js"></script> <met ...

Tips for managing an event using the bxSlider callback API

I am currently using bxSlider to create a slideshow on my website. However, I now want to implement a manually controlled slideshow that also displays text content related to each image below the slideshow: Here is the code I have so far: <!--SlideSho ...

Bootstrap 4 does not have the capability to include spacing between two columns

I'm encountering an issue with adding a gutter between 2 columns on my website layout. I have a row that needs to be 1280px wide (based on a reference resolution of 1366x768 with padding of 43px on each side of the page), containing two sections that ...

Is it necessary to include extra spaces following the input?

My HTML code looks like this: <label> <input type="checkbox"> Print document </label> One issue I am facing is that the "Print document" text is always stuck to the checkbox. I am unable to add "Print Document" in a new element or contr ...

Error: Jquery ajax loading scripts out of sequence

Currently, the setup is as follows: When a link is clicked, the code below is executed: $("#main-content").load(url); The content being loaded into main-content primarily consists of html, with 3 script tags at the top and 3 script tags at the bottom (w ...

Transform the post data into a JSON string within the controller

Hello everyone, I have a sample table that I want to share: <table class="table table-bordered" width="100%" cellspacing="0" id="tableID"> <thead> <tr> <th>A</th> <th>B</th> <th>C< ...

I am having an issue with a mobile JQuery collapsible div that is not properly displaying the internal div within the item

Mobile JQuery jquery.mobile-1.0rc2.min.js HTML 5 Asp.net 4.0 I am having trouble with a gridview item-template where I have implemented the collapsible div from JQuery Mobile. The label text within the h3 element can be quite long, and I want to clip it i ...

Integrating a YouTube video in the Google Maps info window with the help of Ajax technology

Currently working on a project for Udacity, my goal is to develop a neighborhood map using Google Maps API alongside Knockout and Ajax to integrate with another 3rd party API. A unique aspect of my approach is focusing on bars in the neighborhood and utili ...

The application of knockoutjs bindings is restricted to specific ids and cannot be used on any

In my project, I have multiple views where each one applies bindings to its own tag individually. Here is a snippet of the code: (Please note that some code has been omitted for brevity. For a more complete example, you can view the full fiddle here: http ...

React does not recognize CSS attributes

I am facing an issue with the CSS styling when using built-in tags like "form-group" in my code. Strangely, the browser does not apply the CSS when I use these built-in tags. However, if I define my own classes, such as "classes.form", the CSS is visible i ...

What is the best way to locate the closing tag for a specific div element?

My HTML code looks like this: <div class="body"> <h1>ddd</h1> <p>dadfsaf</p> <div id="name"> <div class="des">psd</div> <div>www</div> </div> <div&g ...

Issues with implementing Bootstrap Collapse functionality on dynamically generated content using Ajax

I am utilizing Ajax to retrieve some [information] which will then be used to set attributes within a duplicated div. Contained within the div is a bootstrap accordion: <div class='accordion-toggle' data-toggle='collapse' data-targe ...

<p> The box is massive, and its size is a mystery to me

https://i.sstatic.net/xPoDz.png Why is the box around my paragraph tag so large? I suspect this could be why I am unable to move the <p> tag down with margin-top: 50px; .train p { margin: 0; font-size: 2.5vw; } <div class="train"> < ...

Using PHP to substitute a particular HTML tag with new content

Here is an example of HTML code: <div> <h1>Header</h1> <code><p>First code</p></code> <p>Next example</p> <code><b>Second example</b></code> </div> I am tryin ...