Home » vue » Best way for center v-card horizontally and vertically with vuetify

Best way for center v-card horizontally and vertically with vuetify

Posted by: admin November 26, 2021 Leave a comment

Questions:

I’m currently doing the login page of my website but I can’t properly center my v-card horizontally and vertically.
The best score I have is this one:

<template>
    <v-layout align-center justify-center column fill-height>
        <v-flex row align-center>
            <v-card>
                <v-toolbar color="primary" >
                    <v-toolbar-title>Login</v-toolbar-title>
                </v-toolbar>
                <v-text-field label="Email" v-model="email"/>
                <v-text-field label="Password" v-model="password" />
                <v-footer>
                    <div>
                        <v-btn color="primary" v-on:click="login()">Login</v-btn>
                        <p>I don't have account: <a>Register</a></p>
                    </div>
                </v-footer>
            </v-card>
        </v-flex>
    </v-layout>
</template>

<script>
export default {
    name: 'Login',
    data() {
        return {
            email: "",
            password: ""
        }
    },
    methods: {
        login() {
            console.log('login')
        }
    }
}
</script>

But with this, the text threads are compressed and I can’t enlarge it.
Thanks in advance for your help.

Answers:

Try these.

 <v-container bg fill-height grid-list-md text-xs-center>
        <v-layout row wrap align-center>
          <v-flex>
            Hello I am center to vertically using "align-center".
          </v-flex>
        </v-layout>
      </v-container>

or

<v-container fill-height fluid>
  <v-row align="center"
      justify="center">
      <v-col></v-col>
  </v-row>
</v-container>

###

Concise and works in v2+. This will get you a v-card with centered content HORIZONTALLY and VERTICALLY:

<v-card class="d-flex align-center justify-center"  min-height="250">
    Content here...
</v-card>

codepen