Sidebar Text Remains Visible Despite Collapsed Sidebar

I'm working on implementing a sidebar shrink effect when collapsing it using a combination of custom CSS, jQuery, and Bootstrap. The custom CSS and jQuery handle the shrinking effect, while Bootstrap is used for styling purposes. However, I am facing an issue where some elements in the sidebar do not disappear or hide after the collapse animation. Below is a simplified version of the code along with accompanying images for reference.

Any insights into why this might be happening?

Images (before and after):

https://i.sstatic.net/5jfFZ.png

https://i.sstatic.net/4E60q.png

Code:

<!doctype html>
<html lang="en">
<head runat="server">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="603d20202b1611172636657c76657376e06c3d223d3d223d">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
    <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bd9598948f98959e94bbd29294988b92959984f994848fd4aba994888dc194fef0ffe0e0ffefa094fff182ef879fb4fedab98f92">[email protected]</a>/font/bootstrap-icons.css" rel="stylesheet">

    <style>
        /* Styling for 'shrink' effect when Sidebar is open. */
        .not-bs-sidebar {
            -webkit-transition: all 0.8s;
            -o-transition: all 0.8s;
            transition: all 0.8s;
        }

        /* Styling to make Main area fill page when Sidebar is collapsed. */
        .not-bs-main {
            flex: 1;
        }

        /* Styling to collapse Sidebar. */
        .not-bs-sidebar.active {
            width: 0px;
            padding: 0px;
        }
    </style>
</head>

<body>
<form id="form1" runat="server" class="container-fluid">
    <div class="row">
        <div class="col-md-2 bg-primary not-bs-sidebar" id="sidebar" style="padding-top: 50px;">
            <h1>WTF! Why won't this hide?</h1>
        </div>
        <div class="col-md-10 not-bs-main" id="main">
            <div class="row not-bs-header bg-dark">
                <div class="col">
                    <nav class="navbar navbar-expand-md navbar-dark bg-dark">
                        <button type="button" class="btn btn-primary" id="ButtonCollapse">
                            <i class="bi bi-justify"></i>
                        </button>
                    </nav>
                </div>
            </div>
            <div class="row not-bs-body">
                <div class="col" style="height: 400px;">
                </div>
            </div>
        </div>
    </div>
</form>

<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="00652929232f28255d23292828">[email protected]</a>/dist/js/bootstrap.min.js" integrity="sha384-BBtl+eGJRgqQAUMxJ7pMwbEyER4l1g+O15P+16Ep7Q9Q+zqX6gSbd85u4mG4QzX+" crossorigin="anonymous"></script>
<script>
    $(document).ready(function () {
        $('#ButtonCollapse').on('click', function () {
            $('#sidebar').toggleClass('active');
        })
    });
    </script>
</body>
</html>

Answer №1

Consider making this change:

.not-bs-sidebar {
    -webkit-transition: all 0.8s;
    -o-transition: all 0.8s;
    transition: all 0.8s;
}

Update it to include:

.not-bs-sidebar {
    -webkit-transition: all 0.8s;
    -o-transition: all 0.8s;
    transition: all 0.8s;
    overflow: hidden;
}

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's the deal with Bootstrap 5 button variants and gradients?

I've been exploring the customization of Bootstrap 5 buttons using SCSS mixins. I found User ZIM's answer on the "How to change btn color in Bootstrap" thread very helpful as it clearly illustrates how the button-variant syntax works. However, I ...

Update the value dynamically with jQuery's replaceWith function outside of a PHP loop

My goal is to send a stock number to an external PHP file and retrieve the corresponding image using AJAX replaceWith, but I'm encountering an issue where it always returns the same image. Let's take a look at my Index.php - <?php include(& ...

Javascript error - SyntaxError: unexpected token '}' after property list is missing

In my code snippet below: var UserCharacter = { UserID: util.getCookie('u_u'); userUsingThisCharacter: function() { var data = {}; data.UserID = UserCharacter.UserID; $.ajax({ type: "GET", url: util.API_URL + "charact ...

Output: "Obtain a platform that allows for direct printing to a specified local printer."

I am currently facing a challenge with my website that provides box office services by issuing tickets and generating reports. I am exploring how to send tickets (which are currently in PDF format) directly to a specified printer on a client's local P ...

Engaging Conversations with jQuery

In my form, there is an image positioned next to each radio button. The number and content of these radio buttons are retrieved from a database. I am attempting to set up a click event on these images so that when clicked, a brief description of the corres ...

Formatting won't assist in aligning Facebook button

I am currently working on a page that includes a div with a Facebook recommend button. In order to style the Facebook code, I enclosed it with this formatting: <div style="align:center"> <div id="fb-root"></div> <script src=" ...

Verify if the YouTube video is currently playing and execute the script

Currently, I have a video embedded on my WordPress website using the following code: <iframe id="video" width="640" height="360" src="http://www.youtube.com/embed/xxxxxx?enablejsapi=1" frameborder="0" allowfullscreen></iframe> This video is c ...

Incorrect implementation of Bootstrap CSS in Jade template

Currently, I am leveraging Express to construct a website. However, there seems to be an issue with my jade template not displaying the bootstrap grid system accurately. Despite double-checking that my app path is correctly set through app.use(express.stat ...

Tips for altering the appearance of a button:

Upon clicking the subscribe button and successfully subscribing, I want to display an unsubscribe option in my code. To achieve this, I have created two separate divs for each button, thinking that we could toggle between them. <div id ="subscribe_ever ...

Retrieving current element in AngularJS using jQuery

I have 4 templates, each with mouse actions that trigger functions: ng-mouseover="enableDragging()" ng-mouseleave="disableDragging()" Within these functions, I update scope variables and would like to add a class using jQuery without passing any paramete ...

Exploring the Latest Features: Using Angular 7 with Bootstrap Collapse for Dynamic Aria-Controls

I am currently working on creating my own component to use within an *ngFor loop. I am facing an issue where I need a unique value for my Collapse feature. Right now, when I click on the second main row in the table, the collapse feature only shows the inn ...

Unable to display "xyz" using console.log() function upon button click

Why isn't the JavaScript function being executed in this code snippet? <form> <select type="text" name="month" id="month"> <option value="01">January</option> <option value="02">February</option> ...

Transfer the textbox value from page-1 to page-2 seamlessly with the help of AngularJS UI-routing

I'm attempting to transfer the textbox value from Page-1 to Page-2 using the code below, but I am encountering difficulties. Page-1.html <div > <div style="height: 400px"> <h2>Partial view-1</h2> <p> ...

What is the best way to personalize Material UI elements, such as getting rid of the blue outline on the Select component?

Embarking on my journey of developing a React app, I made the decision to incorporate Material UI for its array of pre-built components. However, delving into the customization of these components and their styles has proven to be quite challenging for me ...

Sending a JSON array to a WebMethod

I encountered an issue when attempting to convert an object to a JSON array as a string, resulting in an Internal Server Error. Fortunately, the GetServerTime method is functioning properly. My goal is to send an array of objects to the server and conver ...

Using PHP's header() function in combination with jQuery Mobile to create

Is it possible to redirect using a php header('Location: newpage.php')? Even though I did not encounter any errors, Jquery mobile appears to be unsuccessful in loading the destination page and the address bar remains with the old address. Any s ...

Retrieve all elements from an array using jQuery

How do I extract all the elements from the array outside of the function? $.each(Basepath.Templates, function(i){ templateArray = new Array({title: Basepath.Templates[i].Template.name, src: 'view/'+Basepath.Templates[i].Template.id, descri ...

Issue with event firing is occurring following closure of Foundation reveal

On my webpage, I have implemented a button that triggers the opening of a modal using jQuery and Foundation. Here is an example of how it appears in the code: $(".playersScores").unbind('click').bind('click', function () { $(' ...

Applying media queries to incorrect screen sizes

My media query seems to be behaving oddly. @media only screen and (max-width: 1200px) { .tool-panel { margin: 0px 24px 0px 0px; } } It is getting applied at 1183.20px instead of 1200px. This discrepancy is consistent across all browsers ev ...

Issues with Cordova and JQuery ajax functionality not operating as expected

I am facing an issue with implementing AJAX functionality in my Cordova app (CLI 6.3.1) on Visual Studio 2017. It works fine on the emulator, but I encounter a connection error when installing it on a mobile phone. I have already included CSP as shown bel ...