Vuetify网格列包裹填充全高

时间:2020-01-28 16:38:19

标签: css vue.js vuetify.js

在网格系统中使用v卡创建组件后,系统ID未填满。我使用了d-flex,但是它没有按预期工作。

带有白色v-card的中间列应填充整个列的高度,但是它会堆叠在顶部。 这是所需功能的图片: enter image description here

这是代码,在Codepen中,您可以看到它没有扩展到整个列的高度,而是嵌套在顶部。

var car = Vue.component('car', {

  template: `
    <div class="car">
         <v-flex d-flex child-flex>
        <v-card >
            <v-card-text>
                <div class="text-center font-weight-black title text--primary">
                    test
                </div>
                <div class="text-center">
                    data
                </div>
            </v-card-text>
        </v-card>
        </v-flex>
    </div>
  `
})

new Vue({
  el: '#app',
  data: () => ({
    lorem: `Lorem ipsum dolor sit amet, mel at clita quando. Te sit oratio vituperatoribus, nam ad ipsum posidonium mediocritatem, explicari dissentiunt cu mea. Repudiare disputationi vim in, mollis iriure nec cu, alienum argumentum ius ad. Pri eu justo aeque torquatos.`
  }),
  components: {"car":car}
})
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <v-app id="inspire">
    <v-container fluid grid-list-sm>
      <v-layout row wrap>

        <v-flex d-flex xs12 sm4 child-flex>
          <v-card color="orange lighten-2" tile flat>
            <v-card-text>Card 1</v-card-text>
          </v-card>
        </v-flex>
        
        <v-flex d-flex xs12 sm2>

          <v-layout column wrap>
            <car></car>
            <car></car>
            <car></car>
          </v-layout>
        </v-flex>

        <v-flex d-flex xs12 sm6>
          <v-card color="red lighten-2" dark tile flat>
            <v-card-text>{{ lorem }} {{ lorem }} {{ lorem }} {{ lorem }} {{lorem}}</v-card-text>
          </v-card>
        </v-flex>
   
         <v-flex d-flex xs12 sm4 child-flex>
          <v-card color="purple lighten-1" tile flat>
            <v-card-text>{{lorem}}</v-card-text>
          </v-card>
        </v-flex>
        <v-flex xs12 sm2 child-flex>
          <v-card color="green lighten-2" tile flat>
            <v-card-text>{{lorem}}</v-card-text>
          </v-card>
        </v-flex>
        
        <v-flex d-flex xs12 sm6 child-flex>
          <v-card color="blue lighten-2" tile flat>
            <v-card-text>{{lorem}} {{lorem}}</v-card-text>
          </v-card>
        </v-flex>
       
      </v-layout>
    </v-container>
  </v-app>
</div>

2 个答案:

答案 0 :(得分:2)

您可以将grow添加到汽车外部div,并将fill-height添加到v-flex ...

<div class="car grow">
    <v-flex d-flex child-flex class="fill-height">
      <v-card>
        <v-card-text>
            <div class="text-center font-weight-black title text--primary">
                test
            </div>
            <div class="text-center">
                data
            </div>
        </v-card-text>
      </v-card>
    </v-flex>
</div>

https://codeply.com/p/qOKz9Qsv6L

答案 1 :(得分:1)

在您的car组件中,删除第一格。

var car = Vue.component('car', {
  template: `
     <v-flex d-flex child-flex>
        <v-card >
            <v-card-text>
                <div class="text-center font-weight-black title text--primary">
                    test
                </div>
                <div class="text-center">
                    data
                </div>
            </v-card-text>
        </v-card>
     </v-flex>
  `
})