简体   繁体   English

如何对齐 ngx-bootstrap 日期选择器

[英]How to align ngx-bootstrap datepicker

I want to customize the ngx-bootstrap datepicker.我想自定义 ngx-bootstrap 日期选择器。 I want to align left/right side of my input, but it doesn't work.我想对齐输入的左/右,但它不起作用。

<div class="col-xs-12 col-12 col-md-4 form-group">
    <input type="text"
           placeholder="Datepicker"
           class="form-control"
           bsDatepicker
           [bsConfig]="{ adaptivePosition: true }">
  </div>

Now it works like this现在它像这样工作

But I want something like that但我想要这样的东西

I couldn't find any way to customize the datepicker.我找不到任何方法来自定义日期选择器。 Can anyone help with this problem.任何人都可以帮助解决这个问题。

Use the placement property to align the datepicker.使用placement 属性来对齐日期选择器。 You can safely remove the adaptivePosition and position using the placement property alone.您可以单独使用placement属性安全地删除adaptivePosition和位置。

<input type="text"
       placeholder="Datepicker"
       class="form-control"
       bsDatepicker
       placement="bottom right">
   // placement="top" -- add this
    
    <input type="text"
           placeholder="Datepicker"
           class="form-control"
           bsDatepicker
           placement="top">


options are : "left" | "right" | "top" | "bottom"

I couldn't do it with Johns Mathew solution because placement="bottom right" is not a valid option, as Falcon mentioned.正如 Falcon 所提到的,我无法使用 Johns Mathew 解决方案来做到这一点,因为placement="bottom right"不是一个有效的选项。 What I did was wrap the datepicker in a container and did some little workaround:我所做的是将日期选择器包装在一个容器中并做了一些小解决方法:

<div class="input-group datepicker-right"> <-- Container
     <input type="text" #dpData="bsDaterangepicker" bsDaterangepicker>
     <a class="input-group-text" (click)="showCalendar(dpData)">
       <i class="la la-calendar"></i>
     </a>
</div>

And I created a css class:我创建了一个 CSS 类:

.datepicker-right bs-daterangepicker-container {
   top: 33px !important; /* Height of my input */
   left: unset !important;
   transform: none !important;
   right: 0px !important;
}

And voilà!瞧!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM