首页 > 解决方案 > 如何在vuetify中水平对齐项目

问题描述

我被困了好几个小时,只是为了在 v-card 中垂直和水平对齐一个项目。下面这张图片是我目前拥有的,我只需要垂直对齐项目,但我不知道如何。谁能帮我?提前致谢

在此处输入图像描述

我的代码:

<div class="pt-3">
        <v-card class="pa-3">
            <v-row align="center" justify="center" v-bind:style="{ height: deviceHeight * 0.6 + 'px',}">
                <v-col class="fill-height" height="500">
                    <v-card class="text-center grey" height="100%">
                        <div align="center" justify="center">
                            <v-icon>mdi-camera</v-icon>
                            <h3>Upload</h3>
                        </div>
                    </v-card>
                </v-col>
            </v-row>
        </v-card>
    </div>

computed: {
    deviceHeight(){
        return this.$vuetify.breakpoint.height;
    },
    deviceWidth(){
        return this.$vuetify.breakpoint.width;
    },
},

标签: vue.jsvuetify.jsnuxt.js

解决方案


和属性用于一些 Vuetify 组件,但它们不适用于原生alignHTML 。而是在...上使用适当的类justifydivv-card

     <v-card class="text-center grey d-flex flex-column align-center justify-center" height="100%">
             <div>
                 <v-icon>mdi-camera</v-icon>
                 <h3>Upload</h3>
             </div>
     </v-card>

演示


推荐阅读