我正在使用Vuetify 3,try 为表格设置自定义页面.一切进展顺利,除了<v-select>使用Flex忽略了宽度这一事实.

<template>
  <v-app>
    <v-row class="mt-2">
      <v-col cols="12" sm="12">
        <div class="d-flex flex-wrap ga-3 justify-end">
          <!-- Items per Page -->
          <v-select
            class="d-flex align-center"
            label="Items per page"
            density="comfortable"
            :model-value="itemsPerPage"
            :items="['5', '10', '25', '100']"
            variant="outlined"
            @update:model-value="itemsPerPage = parseInt($event,10)"
            style="max-width: 150px"
          ></v-select>
          <p class="d-flex align-center">
            {{ page * itemsPerPage - itemsPerPage + 1 }} - {{ page *
            itemsPerPage }} of {{ total }}
          </p>
          <!-- Pages selection -->
          <v-pagination
            class="d-flex align-center"
            density="comfortable"
            rounded="circle"
            v-model="page"
            :length="pageCount"
            :total-visible="6"
          ></v-pagination>
        </div>
      </v-col>
    </v-row>
  </v-app>
</template>

还有 playbook 部分(仅限ref人,仅此而已)

<script setup>
  import { ref } from 'vue'

  const page = ref(1)
  const itemsPerPage = ref(10)
  const total = ref(150)
  const pageCount = ref(10)
</script>

如果你观看<v-select>,你会发现有一个style="max-width: 150px"完全被忽视(主要是由于class="d-flex align-center",但我不知道如何让它一起工作).

这里的Vuetify Playground个片段需要更好地理解我的意思.

编辑 :

第一张图片是它现在的样子

enter image description here

这就是我希望select的外观(加上中心对齐,我无法使用页边或填充将其放在一边,但我想要一个更动态的情况)

enter image description here

有什么建议吗?

推荐答案

使用判断器查看多姆,部分问题在于类为v-input__control的内部迪瓦元素没有使用父迪瓦的全宽.将此元素设置为width: 100%会有所帮助.

<style scoped>
  .v-select :deep(.v-input__control) {
    width: 100%;
  }
</style>

Another issue is that there is some space being reserved for an input details element enter image description here

如果您想利用这个空间,您需要删除这个元素.这实际上可以通过props hide-details来完成

隐藏提示和验证错误.当设置为自动时,仅在有消息(提示、错误消息、计数器值等)要显示时才会呈现消息.

像这样添加props :

<v-select
  class="d-flex align-center"
  label="Items per page"
  density="comfortable"
  :model-value="itemsPerPage"
  :items="['5', '10', '25', '100']"
  variant="outlined"
  @update:model-value="itemsPerPage = parseInt($event, 10)"
  style="max-width: 150px"
  hide-details
></v-select>

这应该会达到您想要的外观.

Updated Vuetify Playground

Html相关问答推荐

在CSS中不保持圆形图像形状的边框半径属性

将CSS应用于TD标记内的div

每次在视口中运行动画

如何从卷轴中排除粘性元素?

无法从路径参数获取ID

Div中的图像问题-(TailWind CSS中的网格)

错误时交换表单,成功时使用HTMX重定向

配置了 HTML 视口的 Google Apps 脚本移动网络应用程序无法正确显示

如何防止弹性项目溢出容器?

网格中的图像zoom 不正确

从触发元素移动到有间隙的内容时 CSS 工具提示关闭

下划线在 Bootstrap 5 导航链接下无法正常工作

如何影响 HTML 元素的哪些子元素导致其增长,哪些不增长?

一旦大于最大限制,JQuery 取消 Select 复选框

在选项标签中如何添加Django模板的条件

如何为某些行具有 rowspan 的表的每个奇数行着色

如何根据行中的其中一列将行居中?

无法从社交栏中 Select 选项

基本上,我想要两列包含文本和图像,但第二列是倒置的

动态使用时波浪号不转换为绝对路径