Fixing the Responsive Menu Issues

In order to achieve the desired effect of making the text from menu and logo disappear when minimizing the menu, you can use the following approach:

Create a function called `smallNav()` to handle the resizing of the sidebar container:

function smallNav() {
            let menu = document.getElementById('sidebar-container');
            menu.style.width = "5rem";
        }

Then, style the elements using CSS to include transitions and animations for a smoother visual effect:

.router-link-active {
            background-color: #2b445f;
            font-weight: 700;
            border-left: 3px solid #1089ff;
        }

        #right, .left {
            cursor: pointer;
        }

        #sidebar-container {
            min-height: 100vh;
            transition: 400ms;
            bottom: 0;
            width: 18rem;
            background: #23374d;
        }

        #sidebar-small {
            min-height: 100vh;
            transition: 400ms;
            bottom: 0;
            width: 0px;
            background: #23374d;
        }

        /* Additional styles go here */
        

Answer №1

If you want to modify your source, try making the following adjustments. The CSS remains unchanged, but I made some modifications to your HTML tags and JavaScript code.

function toggleSidebar() {
        let sidebar = document.getElementById('sidebar-container');
        sidebar.style.width = "4rem";

        document.getElementById('logo-name').hidden = true;

        for(i=0; document.getElementsByClassName('menu-title').length - 1; i++)
            document.getElementsByClassName('menu-title').item(i).hidden = true;
    }
<div>
    <div class="d-flex">
        <div class="bg-primary text-left" id="sidebar-container">
            <div class="logo p-3 d-flex justify-content-between align-items-center">
                <h4 class="text-white" id="logo-name">Company Name</h4>
                <div class="i fas fa-chevron-circle-left left" id="left" onClick="toggleSidebar()"></div>
            </div>
            <div class="menu d-flex flex-column">
                <router-link class="nav-link mt-4 d-flex py-3" :to="{name: 'Home'}" exact="true">
                    <div class="d-flex align-items-center"> <i class="fas fa-home mr-3 menuicon"> </i><span class="menu-title">Home</span></div>
                </router-link>
                <router-link class="nav-link text-white py-3" :to="{name: 'About'}">
                    <div class="d-flex align-items-center"> <i class="fas fa-home mr-3 menuicon"></i><span class="menu-title">Plan</span> </div>
                </router-link>
            </div>
        </div>
        <div class="w-100">
            <nav class="navbar navbar-expand-lg navbar-light bg-light">
                <div class="container-fluid pl-0 pr-0">
                    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
                    <form class="form-inline my2 position-relative d-inline-block">
                        <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" />
                        <button class="btn position-absolute btn-search" type="submit"><i class="fas fa-search"> </i></button>
                    </form>
                    <div class="collapse navbar-collapse" id="navbarSupportedContent">
                        <ul class="navbar-nav ml-auto">
                            <li class="nav-item dropdown"><a class="nav-link dropdown-toggle d-flex align-items-center" id="navbarDropdown" href="#" role="button" data-toggle="dropdown" ariahaspopup="true" ariaexpanded="false"><img class="avatar mr-2 img-fluid" src="https://www.kindpng.com/picc/m/464-4644512_circle-avatar-picture-png-transparent-png.png" />Jan Kowalski</a>
                                <div class="dropdown-menu" aria-labelledby="navbarDropdown"><a class="dropdown-item" href="#">My Profile</a><a class="dropdown-item" href="#">Subscription</a>
                                    <div class="dropdown-divider"></div><a class="dropdown-item" href="#">Logout</a>
                                </div>
                            </li>
                            <div class="d-none" id="mobile">
                                <li class="nav-item"></li>Home
                                <li class="nav-item"></li>About
                                <li class="nav-item"></li>About
                            </div>
                        </ul>
                    </div>
                </div>
            </nav>
        </div>
    </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

Using Firebase to interact with data: $add(), .push(), and .set()

Utilizing Firebase and AngularFire has opened up many different approaches for CRUD operations with the Firebase API. However, I am still uncertain about the specific differences between using: $add with $firebaseArray The .push() method The .set() metho ...

Finding the host name of a client machine using Node.js

Is there anyone who can assist me in obtaining the client's machine name or host name for authentication on my website, which is operating internally within my company domain? I attempted the code below but received the server's host name instead ...

I am having trouble figuring out the issue with the state and how to properly implement it in Typescript

I am having difficulties sending emails using Nodemailer, TypeScript, and NextJS. The contact.tsx file within the state component is causing errors when using setform. As a beginner in TypeScript, I have been unable to find a solution to this issue. Any he ...

Navigating between two table components in React JS

I am a beginner in the world of React and I am struggling with switching between these two tables. Despite consulting the documentation for inline conditional statements, I still couldn't figure it out. My goal is to have the tables switch after click ...

Tips on how to generate a list of checkboxes within a View using ASP.NET MVC

Having some trouble with my View and model when it comes to displaying checkbox lists in lines using bootstrap. They are not appearing how I want them to. Need some assistance and have attached a mock-up below to show how they should look. My approach is o ...

PhpStorm 2019.2 introduces Material UI components that have optional props instead of being mandatory

My PhpStorm 2019.2 keeps showing me a notification that the Button component from Material UI needs to have an added href prop because it is required. However, when I refer to the Material UI API, I see something different. Take a look at this screenshot: ...

Using VueJS to dynamically load a separate component into a Vue instance

Currently, I am working on revamping our web platform at my job. This includes migrating a significant amount of outdated JavaScript/jQuery code to VueJS. We have a "global.js" file that contains our Vue components and a "vendor.js" file that includes Vue ...

How to get the most out of the $scope variable?

Is it possible to assign a regular JavaScript variable the current value of an Angular $scope variable without having their values binded together? //$scope.var1 is set to a specific value, for example, 5 var v2 = $scope.var1; //$scope.var1 is then update ...

How can I use JQuery to iterate through Object data and dynamically create tr and td elements?

In previous projects, I utilized Vanilla JS to iterate through Ajax return data and construct tables. However, for this current project, I have decided to switch over to JQuery. The main reason behind this decision is that some of the td elements require s ...

Error message in Ionic 2: "Property is not found on type"

Currently, I am working on a project in Ionic 2 and have encountered a stumbling block with a seemingly simple task. My issue lies with a Textbox where I aim to input text that will then be displayed. I found some code on a website (http://www.tizag.com/j ...

extract values from a JavaScript function on a website

Currently, I am facing a challenge in automatically retrieving elements from a webpage and I seem to be stuck on a few things. My approach involves looping through all classes named 'trList' using document.getElementsByClassName('trList&apo ...

Enhancing webpage design by dynamically changing borders and headers using JavaScript

I have implemented a fixed positioning for the table headers using the following code: onScroll={() => { document.querySelector('thead').style.transform = `translate(0,${this.scrollRef.scrollTop}px)`; }} However, when I scroll the ta ...

Utilize useMediaQuery for identifying various breakpoints in your design

Currently, I am working on detecting multiple breakpoints in my application to ensure dynamic column generation on a Grid. Although I have managed to accomplish this task, the code appears somewhat repetitive. Is there a method through which I can simpli ...

Guide on linking Influxdb information in a Vue application using node.js?

I have successfully connected my InfluxDB database to my Vue app and can log data in the terminal using the code below: // index.js import express from "express"; // These lines make "require" available import { createRequire ...

What could be causing my SVG bezier curves to malfunction in Firefox?

Encountered an issue today where diagrams I have generated are not functioning properly in Firefox when created using the getPointAtLength method. Here is a demonstration of the problem: http://jsfiddle.net/xfpDA/9/ Please take note of the comments at th ...

When using the resize property in monaco-editor, it may result in editor popups being obscured or

My current task involves utilizing the deltaDecorations method to display errors in my editor. Feel free to check out my code here: https://gist.github.com/dinager/41578bd658b60cc912a6023f80431810 Below is the output: https://i.sstatic.net/Dtj9A.png ...

Create a JavaScript function without attaching it to the global window object

Can someone please help me with defining a function and using it inside Jquery within the $(document).ready block? function addLeadingZero(number) { return (number < 10 ? '0' : '') + number } I'm not confident that I ha ...

When combining stores, what sets Mobx.inject apart from Mobx.observer?

As I start integrating my store with mobx, a question arises in my mind. What sets apart the usage of observer(['store'],...) from inject('store')(observer(...))? Upon closer examination, it seems that inject is not reactive. So, what ...

How to locate a particular element containing specific text using xpath

I have a unique set of spans to work with: <span> <span>foobar</span> <span>textexampleone</span> </span> Currently, I am attempting to utilize xpath in order to locate the span containing "textexampleone" with ...

Add the div id to the script

Currently, I have a script set up where by clicking on a specific div (for example id=packtoa), it will add a class 'show' to listview items that have a matching class with the clicked div's id. While this system works well, I find myself n ...