【问题标题】:how to align item horizontally in vuetify如何在 vuetify 中水平对齐项目
【发布时间】:2020-11-09 09:27:51
【问题描述】:

我已经被困了好几个小时,只是为了在 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.js vuetify.js nuxt.js


    【解决方案1】:

    alignjustify 属性用于某些 Vuetify 组件,但它们不适用于原生 HTML div。而是在v-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>
    

    Demo

    【讨论】:

      【解决方案2】:

      v-row 的行为与 flex-container 一样,所有像 justifyalign 或任何 flex 容器属性这样的道具都只适用于它。只需将您的 div 更改为 v-row。虽然有一个问题是 v-row 有一些负边距,您可以使用 no-gutters 消除它们

      <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%">
                                  <v-row no-gutters align="center" justify="center">
                                      <v-icon>mdi-camera</v-icon>
                                      <h3>Upload</h3>
                                  </div>
                              </v-card>
                          </v-col>
                      </v-row>
                  </v-card>
              </div>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-05-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-09-14
        • 2021-05-03
        • 2017-03-27
        • 1970-01-01
        相关资源
        最近更新 更多