首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在vuetify 2.0中,如何让元素填充剩余的高度?

在vuetify 2.0中,如何让元素填充剩余的高度?
EN

Stack Overflow用户
提问于 2019-08-14 22:12:22
回答 1查看 17K关注 0票数 5

我正在尝试创建一个视图,其中有一个顶部元素,第二个元素垂直居中于其下方的剩余空间中。

在我的尝试中,在第二个元素下面添加了一段空白,它扩展了页面的高度,而不是像预期的那样填充它。

这个问题的再现可以在这里找到:https://codepen.io/R3d4rmy/pen/BaBjvwy

代码语言:javascript
复制
<div id="app">
  <v-app id="inspire">
    <v-app-bar app color="indigo" dark>
      <v-toolbar-title>Application</v-toolbar-title>
    </v-app-bar>
        <v-content>
            <v-container fluid class="fill-height">
        <v-row class="fill-height">
          <v-col
            cols="12"
            sm="10"
            offset-sm="1"
            md="8"
            offset-md="2"
            lg="6"
            offset-lg="3"
            xl="4"
            offset-xl="4"
          >
            <v-row class="fill-height">
                <v-col cols="12">
                  <v-row class="no-gutters">
                    <v-col cols="12">
                      <v-card class="mb-6" outlined>
                        <v-card-title>
                          Title
                        </v-card-title>
                        <v-card-text>
                          <div class="subtitle-2">
                            Subtitle
                          </div>
                        </v-card-text>
                        <v-divider class="mx-4"></v-divider>
                        <v-card-text>
                          <v-text-field
                            flat
                            single-line
                          ></v-text-field>
                        </v-card-text>
                      </v-card>
                    </v-col>
                  </v-row>
                  <v-row class="fill-height no-gutters" align="center">
                    <v-col cols="12">
                      <v-row class="no-gutters" justify="center">
                        <v-col align-self="center" cols="12">
                          <v-card class="mb-6" outlined>
                            <v-card-title>
                              Why is there extra whitespace below this v-card?
                            </v-card-title>
                            <v-card-text>
                              <div class="subtitle-2">
                                And how do I get this v-card properly centered in the remaining space below the first v-card?
                              </div>
                            </v-card-text>
                          </v-card>
                        </v-col>
                      </v-row>
                    </v-col>
                  </v-row>
                </v-col>
            </v-row>
          </v-col>
        </v-row>
      </v-container>
    </v-content>

    <v-footer color="indigo" app>
      <span class="white--text">&copy; 2019</span>
    </v-footer>
  </v-app>
</div>

我觉得我可能在升级到2.0之后误解了语法,没有以正确的方式使用v-row和v-col和fill-height。感谢您的帮助,谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-08-16 04:48:26

看起来你使用了太多的v-row和v-cols。如果你只是想要一张又一张的卡片堆叠成一列,你可以去掉很多这样的东西。修改后的代码在这里:https://codepen.io/CodingDeer/pen/KKPzxYW

代码语言:javascript
复制
<div id="app">
  <v-app id="inspire">
    <v-app-bar app color="indigo" dark>
      <v-toolbar-title>Application</v-toolbar-title>
    </v-app-bar>
        <v-content>
            <v-container fluid class="full-height">
        <v-row class="fill-height">
          <v-col
            cols="12"
            sm="10"
            offset-sm="1"
            md="8"
            offset-md="2"
            lg="6"
            offset-lg="3"
            xl="4"
            offset-xl="4"
          >
            <v-card class="mb-6" outlined>
              <v-card-title>
                Title
              </v-card-title>
              <v-card-text>
                <div class="subtitle-2">
                  Subtitle
                </div>
              </v-card-text>
              <v-divider class="mx-4"></v-divider>
              <v-card-text>
                <v-text-field
                              flat
                              single-line
                              ></v-text-field>
              </v-card-text>
            </v-card>
            <v-col cols="12" class="pa-0 fill-height" justify-self='center'>
              <v-row
                align="center"
                justify="center"
                class="fill-height"
              >
                <v-card outlined>
                  <v-card-title>
                    Why is there extra whitespace below this v-card?
                  </v-card-title>
                  <v-card-text>
                    <div class="subtitle-2">
                      And how do I get this v-card properly centered in the remaining space below the first v-card?
                    </div>
                  </v-card-text>
                </v-card>
              </v-row>
            </v-col>
          </v-col>
        </v-row>
      </v-container>
    </v-content>

    <v-footer color="indigo" app>
      <span class="white--text">&copy; 2019</span>
    </v-footer>
  </v-app>
</div>
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57496441

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档