nico nico - 1 year ago 123
HTML Question

Bootstrap Datepicker: Misaligned

I'm trying to implement a bootstrap datepicker for a website. The issue is that the calendar modal becomes misaligned since some of the css (which I don't have access to) adds a margin to the body and the modal is positioned absolutely.


body {
margin-top: 110px !important;

<link href="" rel="stylesheet"/>
<link href="" rel="stylesheet"/>
<script src=""></script>
<script src=""></script>

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

Here is jsfiddle demonstrating the problem.

What's the easiest work around? Adding a fixed top margin through javascript would work but is incredibly hacky. Is there a better solution?

Answer Source

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

That should fix the issue, here is a link to a fork of your jsfiddle:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download