javascript - 如何修复 Tailwindcss div 高度溢出父 div
问题描述
我的卡片元素有一个固定高度h-80
(在 Tailwind 中)。通常我在网格中使用卡。
现在,我在该卡片中有一个 div,它比它的父 div 大,但是我希望它垂直滚动。现在问题变成了,我不能完全向下滚动。最后一行被切断。
我使用 VueJS 作为框架,这是我的 Card 组件:
<div class="w-full overflow-hidden h-full px-3 py-2">
<div v-if="title" class="block text-gray-700 text-lg font-semibold py-2 px-2">
<i :class="title_icon" />
{{ title }}
</div>
<div class="h-full overflow-y-auto">
<slot>
<-- Here is another component which holds the appointments-->
</slot>
</div>
</div>
如何用 TailwindCSS 中的溢出内容填充 div 中的剩余空间?
解决方案
使用flex-grow
sub-div 上的属性允许它增长。flex
在父 div 上设置并flex-col
保持样式。在此处查找文档
<div class="flex flex-col w-full overflow-hidden h-full px-3 py-2">
<div v-if="title" class="block text-gray-700 text-lg font-semibold py-2 px-2">
<i :class="title_icon" />
{{ title }}
</div>
<div class="flex-grow h-full overflow-y-auto">
<slot>
<-- Here is another component which holds the appointments-->
</slot>
</div>
</div>
推荐阅读
- html - 从空的类标签 (HTML) 中抓取
- crud - CakePHP3 CRUD API 和 API 路由
- java - 用单独的颜色显示国家
- r - 在 R 中分离数据
- javascript - JS:chrome 开发工具中对 JS 文件的更改未反映
- android - Glide 和 Picasso 无法从 YouTube 加载图像
- php - 是否可以将函数存储在数组中并根据 if 语句结果调用它们?
- powershell - “AND”没有按预期运行
- python - 传递 1 2 23 32 4 在 python 的 max 函数中返回 4,为什么?
- google-cloud-platform - 使用 google_cloud_scheduler_job 调度批处理作业