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

如何调整FullCalendar表头单元格高度以去除月份文本上下空白?

Fixing Extra Vertical Space Around FullCalendar Month Header Text

Got it, let's get rid of that annoying extra padding above and below your FullCalendar month text once and for all. Here's a step-by-step solution tailored to different FullCalendar versions:

1. Identify the Target Elements First

Fire up your browser's DevTools (F12), click the element picker, and select the month text (e.g., "June 2024"). This will show you the exact CSS classes applied to the text and its parent container—critical because class names vary slightly between FullCalendar versions.

2. Custom CSS to Strip Out Extra Space

For FullCalendar v5/v6 (Most Common)

These versions use fc-toolbar-title for the month text and fc-toolbar-chunk for its parent container. Add this CSS to your project:

/* Remove padding/margin from the month title itself */
.fc-toolbar-title {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
  line-height: 1.1 !important; /* Adjust based on your font size to keep text vertically aligned */
}

/* Remove padding from the parent chunk if it's adding extra space */
.fc-toolbar-chunk {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

For Older FullCalendar Versions (v4 and below)

Older versions use fc-title inside the fc-center container. Use this instead:

.fc-center .fc-title {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
  line-height: 1.1 !important;
}

3. Avoid !important (Optional but Clean)

If you want to skip !important, boost your selector specificity by wrapping it in your calendar's parent container class. For example:

#my-custom-calendar .fc-toolbar-title {
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
  line-height: 1.1;
}

Just replace #my-custom-calendar with the ID/class of the element wrapping your FullCalendar instance.

4. Double-Check for Date Header Cells (If Needed)

If you're also referring to the day-of-week header cells (e.g., "Mon", "Tue") having extra space, target those with:

.fc-day-header {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  line-height: 1.1 !important;
}

Test these styles and tweak the line-height value if needed—this ensures your text stays vertically centered without any wasted space above or below.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 08:22:36