【问题标题】:Vuetify - display a header and a v-card together with full size verticallyVuetify - 垂直显示标题和 v-card 以及全尺寸
【发布时间】:2021-05-05 13:49:17
【问题描述】:
<template>
  <div>
    <div style="height: 20px; color: yellow">
      test
    </div>
    <v-card class="markdown-preview" tile>
      <v-card-text v-html="previewText"> </v-card-text>
    </v-card>
  </div>
</template>

无论标题 div 的大小如何,v-card 都应该占据 div 中的剩余位置。 我用 flex 尝试过,但是 v-card 要么直接在顶部,要么在底部溢出父 div。 有人可以帮帮我吗?我花了几个小时尝试了很多不同的选择。我唯一的解决方案是计算 CSS 属性。但我希望这些值是可变的。

【问题讨论】:

  • 尝试在v-card上使用height: 100%
  • 然后它溢出底部。我是 100% 的 div,但我只有(100% - 标题 div 的大小)的位置。

标签: javascript html css vue.js vuetify.js


【解决方案1】:

您可以为此使用 display flex。 将 parent 定义为 display: flex,然后将 v-card 定义为 flex: 1

<template>
    <div style="display: flex; flex-direction: column;">
        <div style="height: 20px; color: yellow">
            test
        </div>
        <v-card class="markdown-preview" style="flex: 1;" tile>
            <v-card-text v-html="previewText"> </v-card-text>
        </v-card>
    </div>
</template>

【讨论】:

  • 感谢它的工作!但我还有一个问题。我也有一个高度灵活的页脚。我为此使用 v-footer-bar 。但是内容忽略了页脚。如果我将页脚包装在一个 div 中并给它一个高度,一切正常。但我不知道每次的高度。
  • 您可以使用height: auto,页脚会根据内容自动调整。
  • 是的,我试过了,但高度自动给页脚的高度为 0,内容直接在底部。如果我在没有包装 div 的情况下直接使用页脚,则页脚的大小合适,但内容也直接位于底部。
  • 啊,我做到了,这是因为页脚的绝对属性..
猜你喜欢
  • 1970-01-01
  • 2021-02-06
  • 2011-10-08
  • 2019-06-30
  • 2020-07-20
  • 1970-01-01
  • 2018-12-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多