You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何调整BsDatePicker的尺寸(高度与宽度)?

调整BsDatePicker尺寸的方法

BsDatePicker官方配置属性中确实没有直接设置高度和宽度的选项,你可以通过自定义CSS样式来调整它的尺寸:

  • 调整输入框尺寸
    给日期选择器的输入框添加自定义类,然后通过CSS设置宽高:

    /* 自定义输入框样式 */
    .custom-date-picker-input {
      width: 220px;
      height: 42px;
      padding: 0.5rem;
    }
    

    在模板中绑定该类:

    <input type="text" class="custom-date-picker-input" bsDatepicker>
    
  • 调整弹出日历面板尺寸
    日历面板的默认类为bs-datepicker-container,可以直接针对该类设置样式,若默认样式优先级更高,可添加!important强制覆盖:

    /* 调整日历面板宽度 */
    .bs-datepicker-container {
      width: 320px !important;
    }
    /* 调整日历单元格高度,间接改变面板整体高度 */
    .bs-datepicker-body table td, .bs-datepicker-body table th {
      height: 38px;
      line-height: 38px;
    }
    

内容的提问来源于stack exchange,提问作者developer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 08:22:02