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

Bootstrap 4(v4.1.1)日期时间选择器下拉异常求助及替代方案推荐

Hey there! Let's get that wonky datetime picker dropdown sorted out for your Bootstrap 4.1.1 project, and also share some solid plugin options that play nice with this specific Bootstrap version.

First, Diagnosing the Dropdown Display Issue

From your code snippet, it looks like you're using an input group setup for the datetime picker—this structure is correct for Bootstrap 4, but the dropdown glitch is almost always due to plugin-Bootstrap version incompatibility or missing dependencies.

For example, if you were using an older version of a popular picker like eonasdan Bootstrap Datetimepicker, it might not fully support Bootstrap 4.1.1's CSS classes and layout rules, leading to broken dropdown positioning or styling.

Quick Fix for Existing Setup

If you want to stick with a Bootstrap-native picker, here's how to fix it:

  1. Use the right dependency stack (order matters!):

    • jQuery 3.x (compatible with Bootstrap 4.1.1—avoid jQuery 4+ here)
    • Moment.js (required for most datetime pickers to handle date parsing)
    • Bootstrap 4.1.1 CSS + JS
    • A datetimepicker plugin built explicitly for Bootstrap 4 (like the updated Tempus Dominus Bootstrap 4, the official successor to eonasdan's picker)
  2. Update your HTML & initialization code:
    Here's a corrected working example matching your structure:

    <section class="jumbotron text-center ">
      <form>
        <div class="form-row justify-content-md-center">
          <div class="form-group col-md-6">
            <label for="datetimepicker1">Bootstrap 4 (v4.1.1 ) Date Time Picker</label>
            <div class="input-group mb-3">
              <input type="text" class="form-control" placeholder="Suggested time for visit*" aria-label="Suggested time for visit*" aria-describedby="basic-addon2" id="datetimepicker1">
              <div class="input-group-append">
                <span class="input-group-text" id="basic-addon2"><i class="far fa-calendar-alt"></i></span>
              </div>
            </div>
          </div>
        </div>
      </form>
    </section>
    
    // Initialize the picker after all dependencies load
    $(function () {
      $('#datetimepicker1').datetimepicker({
        // Add custom config here, e.g., format: 'YYYY-MM-DD HH:mm'
      });
    });
    
  3. Verify plugin CSS: Make sure the datetimepicker's CSS is loaded after Bootstrap's CSS to avoid style conflicts that break the dropdown.

If you're looking to switch to a more reliable option, these are top picks:

  • Tempus Dominus Bootstrap 4: The official, maintained successor to eonasdan's picker. Fully compatible with Bootstrap 4.x, has extensive configuration options, and supports both date and time selection.
  • Flatpickr: A lightweight, jQuery-free picker that integrates seamlessly with Bootstrap 4 styles. Highly customizable, mobile-friendly, and has no heavy dependencies.
  • Bootstrap Datepicker: A simpler option if you only need date selection (not time). Lightweight and built specifically for Bootstrap 4.

All these plugins have clear documentation to help you set them up quickly with your Bootstrap 4.1.1 project.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 08:56:33