javascript - 如何在 Vuetify 中不使用“md/sm”将所有图块设置为特定宽度?
问题描述
<v-row no-gutters>
<v-col class="item" v-for="(item, index) in items" :key="index">
<div class="pa-3" style="width: 120px; height: 200px">
{{ item.name }}
</div>
</v-col>
</v-row>
md="3"
我想在不使用or的情况下将所有图块设置为一定的宽度sm="4"
。
当我测试上面的代码时,浏览器会显示如下结果:
但是,我想将第 16 个图块设置为与其他图块相同的宽度,如下所示:
我不想使用md
or sm
,因为我想单独设置图块的宽度和高度。
如何将所有图块设置为特定宽度,包括最后一个?
这是示例代码:
https ://codesandbox.io/s/vuetify-grid-example-forked-tje7u?file=/src/App.vue
解决方案
我不认为您可以使用v-col
道具来实现这一点,我不建议您覆盖默认样式,但是您可以使用简单的 CSS 规则来实现所需的行为:
<v-container class="pa-1" fluid>
<section class="grid">
<div class="item" v-for="(item, index) in items" :key="index">
<div class="pa-3" style="width: 120px; height: 200px">
{{ item.name }}
</div>
</div>
</section>
</v-container>
风格 :
.grid{
display:grid;
grid-template-columns:repeat(auto-fit,120px)
}
或者您可以做出更多响应:
.grid{
display:grid;
grid-template-columns:repeat(auto-fit,minmax(120px,1fr))
}
推荐阅读
- c# - C# - 解码 base64 字符串 PKCS7 签名 - 充气城堡?
- java - JAVA:将列表拆分为较小的列表,然后将它们流式传输到多个线程中
- griddb - GridDB 服务器启动错误 - 无效的集群名称
- spring-boot - 如何将 application.yml 值默认为空格?
- python - 重命名 col 标题列表
- rebus - 在消息处理程序中如何立即停止处理新消息?
- python - 如何在 python 中将 Plaid 银行 API 响应加载到 pandas 数据框?
- c# - 如何使用正则表达式从字符串的开头和结尾修剪字符?
- ios - CMFormatDescription.h 未知类型名称“AudioFormatListItem”
- json - 从 Excel VBA 中调用和解析 Rest API