如何使bootstrap-ui datepicker和timepicker内联?

时间:2018-05-29 10:08:03

标签: angular datepicker timepicker bootstrap-ui

有没有办法让bootstrap-ui组件显示为内联,如下所示: enter image description here

我尝试了各种各样的东西,但我不能让它们全部对齐。这是Plunkr

  <div class="col-md-6">
    <p class="input-group">
      <input type="text" class="form-control" uib-datepicker-popup="{{format}}" ng-model="dt" is-open="popup1.opened" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" />
      <span class="input-group-btn">
        <button type="button" class="btn btn-default" ng-click="open1()"><i class="glyphicon glyphicon-calendar"></i></button>
      </span>
       <div uib-timepicker ng-model="mytime" ng-change="changed()" hour-step="hstep" minute-step="mstep" show-meridian="ismeridian"></div>
    </p>
  </div>

更新

尝试将uib-timepicker标记从div更改为span,但这会破坏datepicker组件:https://plnkr.co/edit/CjBzCthVyoQAVooi5oR7?p=preview

UPDATE2: 要进行校准,这个问题与此库有关:https://angular-ui.github.io/bootstrap/

UPDATE3: 使用相对单位更新了接受答案中提供的plunkr:https://plnkr.co/edit/TaoVJZwCjh1uLyz3huk9?p=preview

1 个答案:

答案 0 :(得分:1)

  • 将最后div代码更改为span代码。
  • 添加两个新的CSS类:
    • .buttonClass {vertical-align:top; }
    • .timeClass表:first-child {top:-35px;位置:相对; }
  • 将按钮类添加到span,其中包含按钮
  • 将时间类添加到包含时间选择器的span