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

Maintain the state of the toggle div after page refresh or modification

In this scenario, I am looking to ensure that my div remains open even if the page is changed or refreshed. Below is the HTML and JavaScript code provided: You can view the working code here: http://jsfiddle.net/wasimkazi/fauNg/1/ $(".widget2").hide( ...

ReactJS not displaying the class effect as intended

When using the react zoom pan pinch library, I am trying to set the height to "100%" for TransformWrapper and TransformComponent. Interestingly, it works perfectly fine when done through Chrome inspect, but when attempting to add a className or use style={ ...

Locating elements with CSS Selector in Selenium - A complete guide

Currently, my code is set up to access a website and click on each row in the table which then opens a new window. My goal is to extract one specific piece of information from this new window, but I am struggling to utilize CSS selectors to retrieve the f ...

How can I convert the left links in my navigation bar to a CSS drop-down menu to make it more responsive on small screens?

Here is the structure of my HTML (at the top): <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></s ...

Persistent change issue with JQuery CSS function

Looking for some help with a button-bar div that I want to display only after the user clicks on a "settings" button. Currently, I have set the button-bar div to have a display:none property in my css file. However, when the settings button is clicked, t ...

Change the color of the text in a shiny dashboard

While exploring shiny dashboard, I came across this link that explains how to modify colors in the sidebar and header. However, I'm struggling to change the font color for sidebar items. The default white font color becomes unreadable when using light ...

Oops! Looks like there was a syntax error with the JSON data at position 1. This resulted in a 400

Having issues submitting form data in my Vue app with an express backend API. The endpoint works fine on postman but I keep getting errors like "SyntaxError: Unexpected token g in JSON at position 0" or "400: Bad Request." I've tried using JSON.parse ...

Feeling trapped during the process of setting up a intricate jQuery Image Slider

I've hit a roadblock while trying to make changes to the slider located at THIS URL. In the current setup, each thumbnail corresponds to one main display image. Clicking on a thumbnail displays a single image and then proceeds to slide to the next th ...

Implement the color codes specified in the AngularJS file into the SASS file

Once the user logs in, I retrieve a color code that is stored in localstorage and use it throughout the application. However, the challenge lies in replacing this color code in the SASS file. $Primary-color:#491e6a; $Secondary-color:#e5673a; $button-color ...

Is it possible to sanitize user input without relying on !important?

Utilizing wp_editor, I have implemented a front-end form on my WordPress website for users to post without accessing the admin section. Although it is functional, there is a concern that users may copy and paste content with inline styles that could disrup ...

Guide on centering an unfamiliar element in the viewport using HTML, CSS, and JavaScript

In the process of developing my VueJS project, I have successfully implemented a series of cards on the page. However, I am now facing a challenge - when a user selects one of these cards, I want it to move to the center of the screen while maintaining its ...

Header and footer on iPad are not extending to full width even when set to 100% width

Upon viewing this link on an iPad, you may observe that the header does not span the full width of the page, leaving a noticeable pixel gap on the right side. The same issue is present with the footer. It is puzzling to me because both elements are set to ...

Content positioned beside an image with the help of Bootstrap 4 framework

How can I align text to the right of an image, like a table layout? I experimented with grid layout using <div class="span2"> and <div class="span10"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bo ...

Can you explain how the CSS hack *+html works?

While working on a project, I have encountered multiple rules that look like this: * + html { /.../ } Although I understand the purpose of using * and +, I am unsure about the significance of this particular construction. Additionally, I came across ...

Merging a prop of array type in a Vue component

I'm encountering an issue in my component where using the splice function on an array prop does not trigger the $emit event. Can anyone provide some insight into why this might be happening? The removeItem method is called by clicking a button. View ...

Using nodemailer to send an email with a dynamic variable that holds the HTML content

I am attempting to send a variable containing HTML code from a Vue component using the POST method. My technology stack includes TypeScript, Nuxt.js, Node.js, and Vue.js. const order_list = document.querySelector('table') as HTMLInputElement | n ...

Guide on generating virtual nodes from a string containing HTML tags using Vue 3

Investigation I stumbled upon this solution for converting a simple SVG with one path layer into Vue2 vnode list and wanted to adapt it for Vue3. After scouring resources, including the MDN docs, I couldn't find any pre-existing solutions. So, I dec ...

What are some ways to ensure a JQM-created button is clickable in Firefox?

I am working on making a div clickable in a jQuery Mobile powered website. The current code I have functions properly in Chrome and Safari, however, it does not work in Firefox - both on desktop and Android FF. <button data-icon="eye"> <a href ...

A guide to implementing drag and drop functionality using JavaScript

I have developed a unique drag and drop application that features both a left and right panel. The issue I am facing is that when I drag the ball from the left panel to the right panel, it does get dragged successfully. However, the problem arises when the ...

Organizing list items into vertical columns

Could you help me with UL/LI syntax and how to create a wrapping list? For example, I would like to display: 1 2 3 4 5 6 As: 1 4 2 5 3 6 Currently, I have a header, content, and footer all set with specified heights. I want the list to wrap when ...