Steps for automatically collapsing the sidebar on mobile devices when the page loads

I recently purchased the Lexa bootstrap admin dashboard from Envato Elements, but I'm encountering a problem. When viewing it on mobile, the sidebar does not collapse by default. The Metis Menu is being used for the sidebar, and clicking on the toggle button collapses it by adding a class to the body called enlarged. Can anyone assist me in resolving this issue? Thank you :)

Sidebar

<div class="left side-menu">
  <div class="slimscroll-menu" id="remove-scroll">

      <!--- Sidemenu -->
      <div id="sidebar-menu">
          <!-- Left Menu Start -->
          <ul class="metismenu" id="side-menu">
              <li class="menu-title">Main</li>
              <li>
                  <a href="index.html" class="waves-effect">
                      <i class="mdi mdi-view-dashboard"></i><span class="badge badge-primary badge-pill float-right">2</span> <span> Dashboard </span>
                  </a>
              </li>
              <li>
                  <a href="calendar.html" class="waves-effect"><i class="mdi mdi-calendar-check"></i><span> Calendar </span></a>
              </li>

              -------------------------

          </ul>

      </div>
      <!-- Sidebar -->
      <div class="clearfix"></div>

  </div>
  <!-- Sidebar -left -->

</div>

Answer №1

One option to incorporate the enlarged class is through Javascript when dealing with a restricted screen size.

if (window.innerWidth < 960) {
    document.querySelector("body").classList.add('enlarged')
}

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

How to manage multiple controllers for the same template in AngularJS?

I am facing a requirement where a single page needs to display a lot of different data, all within one vertical-scrolling page. To manage this, I have implemented collapsible divs on the page controlled by ng-if to efficiently handle the DOM elements. In ...

Deciphering JSON data in an Express.js application

In a Node.js/Express.js application, an API call is made to another server which responds with JSON data. However, the received JSON response is not being properly parsed into new variables. What specific modifications should be applied to the code below i ...

Encountering difficulties when attempting to inject NotifierService into an Angular Service

I am attempting to incorporate Angular NotifierService into my service class so that I can display error notifications in case of any exceptions from the service side. I attempted to inject a bean of NotifierService in the constructor of my service class, ...

Is there a way to apply CSS to an image so that it appears to be resting on a surface like a 3D object

I need to create a 3D floor with cartoons placed on top. The floor has a grid where each cartoon is positioned. I want to maintain the same axis for both the floor and grid, but I need the images and text in each grid element to be at a 90-degree angle to ...

Adding a specified number to a value in React: x + y

I am facing an issue with adjusting the value of deliveryFee based on the changing value of a variable weight. Initially, I have set specific values for deliveryFee based on different weight ranges: Up to 2 kg => $3.40 Up to 5 kg => $3.80 Up to 10 k ...

The submit function for Ajax is not functioning properly

<script> var markerLatitude; var markerLongitude; function initializeMap() { var centerCoordinates = new google.maps.LatLng(51.8979988098144, -2.0838599205017); var mapOptions = { zo ...

What is the best way to extract data from the response using the .getJSON() method in jquery?

function saveCallerReference(callerReference){ $.getJSON('/index.php?r=site/AJAXsaveCallerReference', function(data) { console.log(data); return data; }); } In the context provided, the "return data;" line does not get e ...

Just a quick question about using AJAX

Before submitting my PHP page, I need to send an email. The mail script is in a file called sendmails.php. Is it possible to use JavaScript to send an AJAX request to send the email before submitting the page? Here is an example: function submit_page() { ...

JQuery can be used to dynamically add a class to a table row and ensure that it is saved even

How can I persist the selected row highlight in a Bootstrap table using jQuery even after reloading the page? I have the selected objectName saved in a global variable. Is there a way to leverage this to maintain the highlight upon reload? js page: $(&ap ...

Steps to deactivate a textarea in angularjs based on a selected option's value meeting a specific condition

Hello, I am a newcomer to AngularJS and I am looking to disable the textarea when a specific option is selected from a dropdown menu. I attempted to use ng-disabled="(here my ng-model value)" but unfortunately, it did not work as expected. If creating a ...

What is the best way to remove the current divs using jQuery?

Take a look at this example - http://jsfiddle.net/s11Lbnp8/1/ In my rails application, I have dynamically added a post-wrap. When I click on delete, I want to only remove the wrap related to the button I clicked. I have tried various methods like closest, ...

When the page is resized for mobile, the Bootstrap modal shifts downwards

I am encountering an issue with a modal that pops up on my webpage when clicked. It is perfectly centered in a browser view and smaller views. However, when I resize the page for phones, the modal shifts down the page and requires scrolling to see it. How ...

Is there a way to make my website mirror the exact layout it has on Codepen?

Recently, I started working on a web project on Codepen using Bootstrap 4 and JQuery quick-adds. The results were perfect on Codepen but when I copied the same code to my text-editor and ran it from there, the formatting of the page was completely off. I t ...

AngularJS textbox validation for numbers and required in repeating mode ensures that the user input is a

For more information, please visit the following link: https://plnkr.co/edit/9HbLMBUw0Q6mj7oyCahP?p=preview var app = angular.module('plunker', []); app.controller('MainCtrl', function($scope) { $scope.NDCarray = [{val: '' ...

Tips for emphasizing specific text within HTML tags without highlighting the tags in Vue

I am using a tag with v-html to render HTML text and display it, like so: <div v-html="htmlText"></div> I have written code to highlight text and it works on regular text: Vue.filter('highlight', function (word, query) { ...

"Encountering an issue with Asp.net:FullCalendar where events are not

Hey there! I've been trying to set up FullCalendar on my ASP.NET application by following some tutorials, but unfortunately, when I launch my application, the calendar isn't loading the events. Here's a snippet from my index.chtml file: @{ ...

Ways to insert a hyphen "-" in an HTML form

Currently, I am in the process of designing a form for entering my bank account number. I would like to add a checkbox that will automatically populate the field for easier viewing. <input class="form-control" type="text" placehol ...

Storing user input from a dynamic form into a database using Kendo UI

I've successfully populated dynamic input form fields. However, I'm unsure how to save the data into a database using a put/post API since I have only used a get API so far. HTML code <div id="renderform" class="form horizontal-for ...

Transferring the value of a TextBox to another TextBox in ASP.NET across multiple rows

I have around 10 rows where I need to duplicate the value of one TextBox into another. A specific ID can be assigned to the first TextBox to achieve this, but I am seeking a more general function that can copy TextBox values in each row in ASP.NET. This i ...

Tips for coordinating actions across it blocks

I am currently utilizing protractor for running e2e tests on my angular application. My goal is to synchronize actions between describe or it blocks like this: describe('My spec', function () { doMyAction(); describe('My sub spec 1&ap ...