Align a specified number of v-col components to the center within a Vuetify grid, with additional spacing

Struggling to center a specific number of v-cols with equal spacing on the left and right sides, while also aligning them horizontally with other v-cols. The responsiveness is working fine, but I want to limit it to two v-cols at maximum screen size, aligned with the lengths of the other v-rows.

My current layout looks like this: https://i.sstatic.net/W9Brd.png

Starting from:

<v-container>
  <v-row dense justify="center">
    <v-col cols="12" md="6" lg="4" xl="3">
      // ...
    </v-col>
  </v-row>

  <v-row dense justify="center">
    <v-col cols="12" sm="6" xs="6" md="6" lg="4" xl="3">
      // ...
    </v-col>
    <v-col cols="12" sm="6" xs="6" md="6" lg="4" xl="3">
      // ...
    </v-col>
  </v-row>

  <v-row dense justify="center">
    <v-col v-for="(item, n) in list" :key="n" cols="12" sm="6" md="6" lg="4" xl="4">
      // ...
    </v-col>
  </v-row>

The desired outcome is shown below: https://i.sstatic.net/7n2jJ.png

How can I add spacing to the red v-cols to keep them aligned with the v-cols above (in the previous v-rows)?

Edit: Resolved by updating the code as follows:

<v-container>
<!-- .. other rows -->

<v-row justify="center">
  <v-col cols="24" sm="12" xs="12" md="12" lg="8" xl="6">
    <v-row dense justify="center" class="green">
      <v-col v-for="(item, n) in list" :key="n" sm="12" xs="12" md="12" lg="8" xl="6" class="br text-center red">
        // content
      </v-col>
    </v-row>
  </v-col>
</v-row>
</v-container>

Answer №1

One way to center your layout is by wrapping it with the following code:

<v-row justify="center" align="center">
    <v-col cols="10">
      // Add your layout here
    </v-col>
</v-row>

The v-row element ensures that the columns inside it are centered, while setting the cols property of the v-col element to a number like 10 (or any other value besides 12) provides equal spacing from the sides.

This approach helps in aligning any layout placed within this wrapper.

To see an example of this method in action, you can check out this pen that I have prepared:

View the vuetify layout code pen here

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

Elements with a lower z-index do not have text drawn over them

I am currently facing an issue with a hidden list on a page that is crucial for my menu. Despite setting the z-index of different elements, the text inside a specific div only displays to one side which is causing alignment issues. Using display:none is no ...

Command field in Javascript

I've crafted an exquisite search box for my website, but I'm struggling to make it functional and display search results. Below are the Html and CSS files pertaining to this section of my site: .searchbox{ /*setting width of the form eleme ...

Tips for making a horizontal grid layout with three items in each row

I have a scenario where I need to render a group of Player components using map() loop, and I want them to be displayed horizontally side by side using a Grid component from material-ui. Currently, the components are rendering in a vertical layout: https ...

Troubles with concealing dropdown menu when hovering

I have noticed that this issue has been raised before, but none of the solutions provided seem to fix my problem specifically. The submenu in my menu is not functioning as intended. It should be displayed when hovered over and hidden when not being hovere ...

Create a bookmark system on an HTML page by utilizing the existing heading tags and implementing Javascript

Looking to implement a bookmark system using the headings within my HTML document, based on heading hierarchy. Unfortunately, my attempts have not been successful so far. https://i.stack.imgur.com/CdXjw.png I envision my bookmarks looking something like t ...

Changing color in JQuery based on class and the content of HTML elements

I am attempting to utilize jQuery to extract the inner html of a div with the class name "box_bottom". These divs are dynamically generated by JavaScript, fetching data from XML. As a result, there could be multiple occurrences based on the XML, and I nee ...

Adjust the Vue.js required property to allow null values but not undefined

I need my component to accept both objects and null values, as Vue.js considers null as an object. However, I want the validation to fail if the value is undefined. Here's what I've attempted using vue-property-decorator: @Prop({ required: true ...

Guidance on incorporating static files with Spring MVC and Thymeleaf

I'm seeking guidance on how to properly incorporate static files such as CSS and images in my Spring MVC application using Thymeleaf. Despite researching extensively on this topic, I have not found a solution that works for me. Based on the recommenda ...

When interacting with Chrome, the div gets automatically blurred upon being clicked

While working on the development of our website, we stumbled upon something peculiar. We have a set of divs displayed on the screen, resembling the layout of Pinterest. Upon clicking any of these divs, the content within that particular div is loaded into ...

Customize Material-UI Icons styles in React app

I'm working on a React.js app with Typescript and I need to remove the default visited Material Icons coloring from an anchor tag. Here's the stylesheet I tried: const useStyles = makeStyles((theme: Theme) => createStyles( myAnchor: ...

centered reCAPTCHA

I just started learning PHP and I'm struggling with positioning my reCAPTCHA box within the form. It looks great before submission, but after submitting the form, everything shifts to the left while the results are still centered. Can anyone help me f ...

Adjust the text area to automatically expand or shrink based on the text it contains

Is there a way to automatically adjust the size of a textarea based on its content? Here is the code I am currently using for this purpose: var element = document.getElementById(event.target.id); var content = $(this).val().trim(); if (content == "") { ...

Difficulties linking Dropdown choices with VueJs2

I am facing an issue with my dropdown list that contains document types. I want the selected type to be stored in a data property, specifically the type.name, so that I can use it in a child component. However, for some reason, my selection is not being sa ...

Modifying the property value in a child component using the parent component in VueJS

Hey there, I'm facing an issue where I need to update a prop in my child component when the parent component changes the value. However, I'm attempting to do this in a unique way and running into a problem where the child prop is not being update ...

Top tips for resolving Swiper Js initial loading issues in a Carousel!

After implementing swiper js from , I encountered an issue. The initial loading displays only a single carousel item before the rest start appearing, creating a glitchy effect. To clarify, when the website is loaded, only the first item is visible in the ...

Apply a class using [ngClass] based on an HTML condition within the local scope

In the past, I have utilized [ngClass] to assign classes based on the Boolean value of a variable in the JavaScript/TypeScript. However, I am now curious if it is achievable to apply [ngClass] based on a local HTML boolean value instead? For example: < ...

Tips for enabling resize functionality on individual components one at a time

Check out my Codepen link for the resizable event While using Jquery UI resizable, everything is functioning correctly. However, I am now looking to have the resizable event activate one block at a time. When another block is clicked, the resizable event ...

iOS Safari browser does not support changing the caret color in textarea

Seeking a solution to hide the text cursor (caret) from a textarea on iOS browsers like Safari and Chrome. Despite trying the caret-color property, it does not seem to work. Are there any alternative methods to achieve this? One approach I attempted is b ...

When trying to revisit or reload a Laravel project, the Vue Router URL cannot be found

Each time I revisit the vue-router URL, a 404 page not found error is displayed. My application is built on Laravel 5.8 and defined in web.php file. I have attempted various solutions but none of them seem to be effective. Route::get('/{capture_a ...

Print the page number using HTML and PHP

Is there a way to center page numbers in HTML? I have the code below that echoes the numbers, but they always appear on the left side of the page. I tried wrapping them in a div to center them, which worked, but then each number is enclosed in its own d ...