Issue with collapsed side-menu in Vue using Element-UI

Attempting to create a basic admin panel using the Element UI library has presented me with a challenge.

The issue arises when the sidemenu is hidden, resulting in the content not occupying 100% of the space. To resolve this, I found that disabling menu animation and adjusting its width when collapsed using CSS like so:

aside.menu-collapsed {
    width: 64px !important;
}

https://i.sstatic.net/01CRA.gif

This is how my layout appears:

Template:

<template>
    <el-container>
        <el-aside v-bind:class="[isCollapse ? 'menu-collapsed' : 'menu-expanded']">
            <el-menu :router="true"
                     :default-active="$route.path"
                     :collapse="isCollapse"
                     :collapse-transition="true"
                     class="el-menu-vertical"
            >

                <template v-for="rule in routes">
                    :
                    :
                </template>
            </el-menu>
        </el-aside>

        <el-container>
            <el-header height="100">
                <span v-on:click="collapseSidebar()">
                    <i class="fas fa-bars"></i>
                </span>
            </el-header>

            <el-main>
                <router-view></router-view>
            </el-main>

        </el-container>
    </el-container>
</template>

Css:

<style>
.el-menu-vertical {
    height: 100vh;
}
.el-menu-vertical:not(.el-menu--collapse) {
    width: 100%;
}

.el-header {
    background-color: #b4bbc1;
    color: #333;
    line-height: 56px;
}
</style>

Any suggestions on how to ensure the content width adjusts accordingly when collapsing the sidemenu?

Answer №1

This is the solution I came up with

<el-aside :span="4"  v-bind:style='{"width": (isCollapse? "64px" : "300px" )}'>
. .

<span @click="isCollapse = !isCollapse"><i class="fas fa-bars"></i></span>

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

csslimit overflow display only left side

I am struggling to implement a drag and drop feature resembling a shopping cart. Unfortunately, the content within the box is concealing the div I want to drag when moving out of the box. Is there a method to display only the content on the left side? Che ...

Is my rtk slice's initial state not being saved correctly in the store?

Currently diving into the world of RTK with typescript. I have created 2 slices - one using RTK query to fetch data (called apiSlice.ts) and another utilizing createSlice for handling synchronous state changes in my todo app (named snackbarSlice.ts). The ...

Map checkboxes aren't updating after an array update following a refactor to react hooks

I recently transformed a class component into a function component using hooks. However, I am facing an issue where the checkboxes within a specific mapping are not updating with the checked value. The onChange handler is firing and updating the array corr ...

Implementing a vertical divider line in between columns with Foundation CSS

Here is the HTML code snippet: <link href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.3.0/css/foundation.min.css" rel="stylesheet"/> <div class="card"> <div class="card-section"> <section class="row"&g ...

Info window in Vue Google Maps

I am working on a Vue app that displays a Google Map using vue2-google-map. However, I am facing an issue with implementing maps.infowindow to my marker because there is a lack of Vue.js reference source. Here is the code for my marker template: <Gmap ...

Implementing VueJS on the Google Cloud Platform

Currently, I am developing a web application using Vue CLI 3 and I have configured it with presets like babel, PWA, Vue Router, and css preprocessors. My goal is to deploy this application on Google Cloud's App Engine. However, I am facing an issue in ...

Master the art of creating click events using only CSS

Is it possible to achieve this example using only CSS? If not, what would be the alternative solution? Any JSFiddle examples would be greatly appreciated! How can I also add slashes - should I use an image or can it be done with CSS? And what about the t ...

Upload files using Ajax

Looking to implement Ajax and PHP for file upload functionality. The form includes an <input type="file"> tag, and I aim to enable users to upload a file without having to refresh the page. Any guidance on how to achieve this? While a refresh is no ...

The Bootstrap navigation menu fails to extend the parent div when toggled

When I toggle the button to show the menu on small screens, the menu overflows the parent div with id=contents instead of pushing it down. How can this issue be fixed? Here is the code: <body> <nav id="header" class="navbar navbar-default"& ...

Tips for creating a custom notification container using CSS

I have been tasked with creating a notification display for a web application. The notifications should appear in the bottom right corner of the window and disappear after a certain period. Alternatively, users can click on a notification to dismiss it. Wh ...

Substitute closing parenthesis within a string with a backslash and closing parenthesis

str = 'he)llo)'; wantedStr --> 'he\)llo\)'; Attempting to achieve this result, I used: var wantedStr = str.replace(')', '\\)'); Unfortunately, the output for wantedStr remains as 'he)l ...

Unable to set maximum width for images in Firefox browser

Welcome to my page where I am utilizing the latest version of Bootstrap v3.2.0 I have encountered an issue when using the display: table-cell; CSS property within a div block. Specifically, the max-width: 100%; CSS property does not function as expected f ...

`I'm experiencing difficulty sending JSON data to Typeahead using PHP`

I am having trouble passing an array of data from PHP to typeahead. I have tried various solutions but nothing seems to work. When I display the response on the console, it shows the array of strings but they are not populating in the typeahead field. PHP ...

I encountered a difficulty trying to assign a value to @Input decorators in the spec file

While writing a test case for form submission, I encountered an issue where the Input decorator (e.g. station) value is reassigned during form submission. However, when attempting to define this Input value in the spec file, the component.station value is ...

Recalling a hidden div in a flexbox arrangement

I am facing a challenge with hiding and displaying two aside divs to enable a fullscreen view of my central div main. The layout is created using flexbox to assign proportions, but when I try to redisplay the elements, it disrupts the original design. Belo ...

Terminate the PHP script depending on the result of the JavaScript confirmation prompt

After extracting values from an HTML form in PHP, I perform certain manipulations before updating a record in a MySQL table. To ensure user confirmation before updating the record, I implement a JavaScript prompt. If the user selects "Cancel," the record s ...

Tips on utilizing React and Node to upload text as a file to Google Drive

Are you wondering how to incorporate React.js as the frontend and Node.js as the backend for uploading/reading files from Google Drive? In my attempts, I've tried writing a string as a text file and then uploading it to Google Drive by following this ...

Upon clicking the "show more information" button on the page, JavaScript executes the function to display additional details

<a href="#" class="button">Read More</a><br> I'm currently struggling with programming a button on my website. Specifically, I need the Read More button to display all information related to the CDs I have for sale when clicked. A ...

The function of hasClass within an if statement appears to be malfunctioning

I'm struggling to figure out why my .hasClass function is not functioning correctly. I've implemented the Quick Search jQuery plugin, and below is the code I am using: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.mi ...

What are the steps to resolve the issue of "npm ERR! EEXIST: file already exists, rename" occurring with non-existent files?

Welcome to my first question post. (Please be kind if I make mistakes.) I am using node version 5.6.0. For an assignment, I downloaded a JS web app but am encountering an error that is preventing me from working on it: S:\PersonalCloud\jennyly ...