2016-07-13 5 views
0

私はウェブサイトにbootstrap datepickerを実装しようとしています。問題は、カスケードのモーダルが整列しないことです。なぜなら、私がアクセスできないcssのいくつかがボディにマージンを追加し、モーダルが絶対的に配置されているからです。問題を実証Bootstrap Datepicker:Misaligned

$('.input-test').datepicker({});
body { 
 
\t margin-top: 110px !important; 
 
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/> 
 
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.1/css/bootstrap-datepicker3.min.css" rel="stylesheet"/> 
 
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.1/js/bootstrap-datepicker.min.js"></script> 
 

 
<input class="input-test"></input>

Here is jsfiddle

最も簡単な回避方法はありますか? javascriptを使って固定されたトップマージンを追加すると動作しますが、信じられないほどハッキリです。より良い解決策はありますか?問題を修正する必要があります

+0

はあなたがマニュアルに従ってコンテナ要素を指定しようとしたことがありますか? https://bootstrap-datepicker.readthedocs.io/en/stable/options.html#container –

+0

ええ、私は入力の隣にあるdivに同じ問題を設定しています。 – nico

+0

まあまあ、私がする必要があるのは、コンテナをhtmlタグに設定したことだけです。 – nico

答えて

2

$('.input-test').datepicker({ container: "html" });

、ここにあなたのjsfiddleのフォークへのリンクは次のとおりです。

https://jsfiddle.net/q0s4Lubb/