My current challenge involves integrating a bootstrap datepicker into a website. The problem arises when the calendar modal is misaligned due to some pre-existing CSS that includes a margin on the body element, and the modal is absolutely positioned.
$('.input-test').datepicker({});
body {
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>
This jsfiddle link showcases the issue I am facing.
I'm seeking the most effective workaround for this situation. While adding a fixed top margin through JavaScript might resolve the problem temporarily, it feels like a rather hacky solution. Are there any better alternatives available?