Is there a way to move the cards to the next line within a wrapper when the screen size is reached?

My goal is to showcase multiple elements in cards, obtained from my routing system, much like how I'm setting up my sidebar (which is functioning correctly). I have all the titles and icons ready, and the linking works seamlessly.

This is where I'm facing an issue: When parsing through elements fetched from my routing system, some of them have children. For instance, I have placeholders for "agenda," "session," and "packs & modules." The last element contains two children - "packs" and "modules." However, when I inspect my route file for these elements, each parent is enclosed within a wrapper, creating separate wrappers for "agenda" and "session," and combining both "packs" and "modules" into one wrapper. I don't want the parent to be displayed in this case.

Everything is running smoothly except for one concern. I display all my cards horizontally, and if a wrapper doesn't fit on the screen, it moves to the next row. This behavior is perfect for single-element wrappers. But with wrappers containing children, things get tricky. When a wrapper can't fit on the screen, the entire wrapper shifts to the next line. I only want the child that doesn't fit to move to the next line, not the entire wrapper.

Here is a snippet of my code:

<template>
   <div v-if="!item.hidden&&item.children" class="menu-wrapper">

    <template v-if="!item.hidden&&item.children && hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren) && !item.alwaysShow">
      <app-link :to="resolvePath(onlyOneChild.path)">
        <el-card   :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest} ">
          <div class="contentCard">
            <div class="icon">
              <i :class="onlyOneChild.meta.icon" />
            </div>
            <span class="title">
              {{ generateTitle(onlyOneChild.meta.title) }}
            </span>
          </div>
        </el-card>
      </app-link>
    </template>
  
  ...

</template>

And here's the CSS styling:

<style lang="css" scoped>
  .el-menu--inline span{
    font-size: 0.9em;
  }
  
  ...

</style>

Your help would be appreciated. Thank you!

Edit: To simplify, I have multiple wrappers with cards inside, all in one line. If there was just one card per wrapper, everything would work fine. However, some wrappers contain two or more cards, and when the screen limit is reached (especially on smaller screens), the entire wrapper jumps to the next line instead of just the card that doesn't fit on the same line inside that wrapper.

Answer №1

After encountering a similar issue, I found a workaround and decided to share my solution for the benefit of others who may face the same problem. The key was to ungroup my children components within my routes method. Initially, I was simply returning my $store.state.permission.routes and handling everything in the template. However, I took a different approach by performing all the necessary operations within the routes method and passing an object array containing the ungrouped components.

routes() {
    this.routesData = this.$store.state.permission.routes;
    console.log(this.$store.state.permission.routes);
    let k = 0;

    for (let i in this.routesData) {
        if (!this.routesData[i].hidden && this.routesData[i].children) {
            if (this.hasOneShowingChild(this.routesData[i].children, this.routesData[i]) && (!this.onlyOneChild.children || this.onlyOneChild.noShowingChildren) && !this.routesData[i].alwaysShow) {
                this.result[k] = this.routesData[i];
                this.result[k].meta = this.routesData[i].children[0].meta;
                k++;
            } else {
                let childrens = this.routesData[i].children.filter(item => !item.hidden);

                for (let child in childrens) {
                    this.result[k] = childrens[child];
                    k++;
                }
            }
        }
    }

    return this.result;
}

As for my updated template:

<template>
   <div class="menu-wrapper">

      <app-link :to="resolvePath(item.path)">
        <el-card :index="resolvePath(item.path)" :class="{'submenu-title-noDropdown':!isNest} ">
          <div class="contentCard">
            <div class="icon">
              <i :class="item.meta.icon"></i>
            </div>
            <span class="title">
              {{ generateTitle(item.meta.title) }}
            </span>
          </div>
        </el-card>
      </app-link>
   
   </div>
</template>

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

The error message "Unable to access 'state' property of undefined in Vue" indicates that the 'state'

I'm attempting to create a centralized data store using Vuex and Vue, but I keep encountering an undefined error. The versions of "vuex": "^4.1.0" and "vue": "^2.6.12" are being used in my setup. Everything works fine until I introduce the computed ...

Desktop display issue: Fontawesome icon not appearing

Having trouble getting the fontawesome icon to display properly on my website. It appears in inspect mode, but not on the actual site itself. Any suggestions on how to fix this issue? import React, { Fragment, useState} from "react"; import { Na ...

The presence of ng-show dynamically adjusts the minimum height of a div element

I am encountering an issue with a div that has the class of wrapper. Inside this div, there is a parent div with the class of content-wrapper. The wrapper div includes a conditional directive ng-show which toggles between displaying or hiding its content. ...

Utilizing Dojo widgets in Xpages

I'm having trouble applying CSS to certain dojo elements within my Xpage. Here is the CSS style sheet I am using: .formFields { color: rgb(5, 56, 107); font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-style: normal; font-variant: nor ...

Interactive front end design for decision trees

On the front end, I aim to enable users to influence the outcome of a Decision Tree based on their selections. For my Django-React App, I have adopted the style and tree example from the codeplayer. You can find it here: I am tasked with creating an unor ...

Tips for applying/styling "All Items Center" and "Space Between Items" in CSS and ReactJS

justify-content: space-evenly; seems to be working correctly, but the desired output is not achieved I am aiming for something like this: https://i.stack.imgur.com/iQoWK.png However, this is what I currently have: https://i.stack.imgur.com/1PxGR.png ...

It seems that Firefox is ignoring the word-wrap style when the class of a child element is changed

Take a look at this: var iconIndex = 0; var icons = ['check', 'chain-broken', 'flag-o', 'ban', 'bell-o']; $('button:eq(0)').click(function() { iconIndex = (iconIndex + 1) % icons ...

Combining objects using Vue.js and Axios

After fetching data from an axios request and a fetch call to an RSS feed, I have two objects with fields that serve the same purpose but have different names. See the example below: Two Object The objects currently look like this: Obj1 = {title: "Main te ...

Using Vue.js to conditionally render content based on changes in a variable

I am facing a challenge in rendering a new element once the boolean variable waiting changes to true. The issue arises when transitioning from one v-if statement to another, as the boolean does not update until the first statement is completed. How can I s ...

Aligning items in several columns

Setting up a grid layout where the content is centered can be tricky, but I've found a solution that works well. Take a look at the code snippet below: .outer { width: 100%; height: 100px; margin-top: 10px; m ...

The main div element is experiencing an overflow due to the excessive

I am struggling to create a homepage layout with three columns of varying heights within the 'content' division. The columns keep overflowing onto the content below, causing layout issues. I have attempted using positioning to solve this problem ...

How to refresh component after clearing dates in Vuetify datepicker

Currently, I am working with a datepicker in Vuetify JS and I need to find a way to clear the dates and refresh the component. In addition, there is a v-data table that is filtered based on the dates range array. I am exploring options to either add a &ap ...

Guide to switch background image using querySelector

I am currently trying to figure out how to set the background image of a div block by using querySelector. I have attempted various methods in my test code below, but unfortunately none seem to be working. Can someone please provide assistance? <!DOC ...

What is the best way to utilize overflow with TailwindCSS?

1. The Home Component: import React from "react"; import Title from "./Title"; import TaskInput from "./TaskInput"; import TaskList from "./TaskList"; function Home() { return ( <div className="h-scree ...

Dynamically adjusting the width of an HTML element with ng-style using percentage values in AngularJS

I am facing a challenge where I need to display a progress bar in my UI based on a percentage value stored in a JSON response object. Here is an example of the JSON object: { completionPercent: 42 } The desired UI outcome should look like this: ┌ ...

Decrease in font size observed after implementing Bootstrap 5

The issue arises when I include the Boostrap CDN link, resulting in a change in font size. I discovered that Bootstrap has a default font size, which is why attempts to adjust it using an external style sheet with !important do not succeed. Interestingly, ...

The Bootstrap collapsible feature is causing elements to shift to the adjacent column

I'm currently implementing bootstrap's collapsible feature to showcase a list of stores along with expandable details. However, the issue arises when I expand one of the collapsibles in the left column, causing certain items to shift into the ne ...

Vue js throws a maximum call stack error when updating a Chart component

I have successfully created a line chart using the Chart.js 3.5 library. The chart is responsive, all animations are working fine too. I am currently facing an issue where I am attempting to update the data from a parent component and trigger a chart updat ...

Animate the transition of the previous element moving downward while simultaneously introducing a new element at the top

I currently have a hidden element called "new element" that is controlled by v-if. My goal is to create a button labeled "display" that, upon clicking, will reveal the new element on top after sliding down an old element. How can I achieve this using CSS ...

What is your preferred datepicker for Vue.js 2?

Can anyone recommend a Vue.js 2.0 date picker component that meets my specific needs? I'm in search of one with the following requirements: Ability to select a range - start date and end date. Easily customizable using CSS. Capability to trigger a m ...