Wrapping content in Vue/Vuetify into columns according to screen size

I am working on a parent component that uses a v-for to render instances of the product-box component based on the number of products. Currently, when there are 200 products, they simply stack on top of each other extending the page length like this:

[box]
[box2]
[box3]
[box4]
--page bottom--

Instead of having the page length keep increasing infinitely, I would like the layout to wrap based on the window size as follows:

[box1]  [box3]
[box2] [box4]
--page bottom--

or further down if I make the screen even smaller:

[box1]  [box2] [box3] [box4]
--page bottom--

Parent component code snippet

<div>
    <product-box 
        v-for="(product,index) in this.$store.getters.getProducts"
        :key="index"
        :product = product
    >
    </product-box>
</div>

ProductBox.vue code snippet

<template>
    <div class='products-box-component'>
        <v-row>
            <v-col cols="12">
                <v-row
                >
                    <v-col cols="2" :class="{'products-box': true}">
                            <div class="image-container">
                            </div>
                            <div class="info-container">
                            </div>
                    </v-col>
                </v-row>
            </v-col>
        </v-row>
    </div>
</template>

Answer №1

I have not yet had the chance to explore the component you are currently utilizing. Perhaps consider implementing a grid layout.

.app-list-container {
  // grid http://www.ruanyifeng.com/blog/2019/03/grid-layout-tutorial.html
  width: 100%;
  display: grid;
  justify-content: space-around;
  // justify-content:center;
  justify-items: center;
  align-items: center;
  grid-template-columns: repeat(auto-fill, 60px);
  grid-template-rows: repeat(auto-fill, 60px);
   // grid-row-gap: 10px;
   // grid-column-gap: 10px;
 }
<div class='app-list-container'>
  <div v-for="(product,index) in this.$store.getters.getProducts"
      :key="index"
      class="app-item"
      >
  </div>
</div>

The simplest way to address this requirement would be through CSS.

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

Testing tools for ensuring the functionality and design of the mobile version of a

Is there a way to preview how my website will appear on mobile before it goes live? Most tools I've come across only work for hosted sites. ...

The path-to-regexp in vue-router fails to match an optional group of route path parameters

Exploring Vue.js Router Currently, I am delving into the official vue-router of vue.js. My focus is on implementing route matching using dynamic route matching. With vue-router utilizing path-to-regexp underneath its operations, regex can be employed in ...

Unable to deploy Worker-Loader alongside Vuejs and Webpack

Having some difficulties setting up web workers with Vue cli3. I prefer using the worker-loader package over vue-worker due to its maintenance and contributions. Following the instructions provided by worker-loader, I tried adjusting webpack using vue cli ...

What is the best way to layer four images in a 2x2 grid over another image using CSS as the background

I am attempting to place 4 images of the same size on a 5th image defined as the background. Currently, it looks like this: It works perfectly when the height is fixed, but in my case, the height may vary causing this issue: This problem isn't surp ...

What are some creative ways to generate revenue from my PWA through the Google Play Store, specifically by utilizing Trusted Web

Hey there, I'm currently busy working on a Vuejs (Quasar) PWA and planning to release it on the play store with TWA. I have some concerns about monetization through AdSense. I need to include the Google script in the head tag of my index.html for the ...

Switch up the Thumbnail Image based on the selected category

While testing a shopping site I created, I encountered an issue with changing the banners at the top of the page based on the category the user is viewing. This site is hosted on a server on my localhost, not using wordpress by the way. <div class=" ...

Using JQuery to hide elements by setting CSS display as none instead of block

Is there a way to change the display of a content div to block when a specific tab is selected by the user, while hiding all other content divs? Here is the JQuery code I have tried so far: $(document).ready(function() { function resetTabs() { $("# ...

Using $window.print() in angularjs results in the print preview displaying an empty page

Encountering a strange issue where using $window.print in angularjs results in only the date, page name, page number, and url appearing on the printed page. The rest of the content is missing even though the original page has plenty of it. I suspect the p ...

The issue with the sticky table header functionality is that it is not functioning properly within the Angular Materials mat

Hi there, I'm currently facing some challenges with html/css tables and sticky headers in combination with Angular Material. Within my project, I am utilizing Angular Material's sidenav components such as <mat-sidenav-container>, <mat- ...

Transforming the date format in VUE-JSON-EXCEL

Is there a way to change the date format for the VUE-JSON-EXCEL library? When I click the generate excel button, the date format displayed in the excel is "2022-06-10T18:18:34.000Z" instead of "10/6/2022 18:18:34" I have tried using moment.js but it is n ...

Adjusting the size of a React element containing an SVG (d3)

In my simple react app, I have the following component structure: <div id='app'> <Navbar /> <Graph /> <Footer /> </div> The Navbar has a fixed height of 80px. The Footer has a fixed height of 40px. The Graph i ...

Tips for maintaining the visibility of the dynamic submenu while hovering over either the parent menu or submenu in vuejs

I'm currently working on a dynamic sidebar in vuejs and I need some assistance. The issue I'm facing is that I want the submenu to remain open when hovering over either the parent menu or the submenu itself. However, when I move the mouse away fr ...

Tips to ensure the div remains 100vh in height, even when empty

As I work on a simple webpage with a header, body, and footer, it's essential for me to ensure that the content takes up the entire height of the page using 100vh. However, if I only have plain text in the body section without any child tags, it ends ...

typescript Can you explain the significance of square brackets in an interface?

I came across this code snippet in vue at the following GitHub link declare const RefSymbol: unique symbol export declare const RawSymbol: unique symbol export interface Ref<T = any> { value: T [RefSymbol]: true } Can someone explain what Re ...

Navigating through tabs in a Meteor application: How to maintain the active tab when using the back button

I am working on a multi-page meteor application where each page includes a navigation template. To switch between pages, I am using iron-router. The user's current page is indicated by setting the appropriate navigation link's class to 'ac ...

Why is it necessary to decode JSON stringified objects in Vue props?

When passing a stringifyed object via props to a component, it seems like there is an issue with the data transformation. <my-component :filter="stringobject" ></my-component> stringobject = "{"search_text":"(ciCl ...

Dealing with adding up optional values from v-model in Vue.js can be a challenging task

Within this function, I need to display the remaining amount. remainingAmount: function() { return parseFloat(this.sumAmount) - (parseFloat(this.cash) + parseFloat(this.kNet) + parseFloat(this.kNetOnline)); } The three parameters cash ...

Load CSS stylesheet depending on Internet Explorer document mode

As I work on my website, I am facing the challenge of incorporating different versions of my style sheet based on the browser's document mode, not the browser mode. For instance, if the documentmode = ie8, I may need to load main_ie8.css, whereas for ...

How can I use JavaScript to loop through a specific attribute?

I have implemented ckeditor inline on a website I created. While it allows me to save data to a database, the issue arises when ckeditor automatically applies its own classes and attributes to certain elements where contenteditable is enabled. It also re ...

The picture within the div is not appearing as expected

I am facing an issue with inserting an image in a div container using CSS and HTML. The image is not displaying properly. Here is the HTML code: <div id="wrapper"> <div id="quoteContainer"> <span class="start_img"></span> </di ...