question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Date picker not aligned when there is fixed top menu on page in bootstrap.

See original GitHub issue

When there is a fixed top menu on page in bootstrap we have to add some element with margin top or to add margin to body.

In that case the datepicker is out of input element basically it is shown over input element because it calculates element style top in my case 50px less.

So for example if i open datepicker and inspect with div with datepicker class i see

element.style {
    display: block;
    left: 1261.5px;
    top: 176.8px;
}

screenshot - 180915 - 22 13 53

If i edit that and add 50px, the datepicker shows in place. I can add margin-top: 50px to datepicker class and it would work but that is just quick fix for my specific case.

screenshot - 180915 - 22 14 40

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
raefacommented, Jan 10, 2016

This is not a solution … rather a work around. Calculate the height of the menu at the top and add it to the datepicker on “show”.

$(".date input").datepicker().on("show", function(e) {
var top = $("#organization-header").height() + parseInt($(".datepicker").css("top"));
  $(".datepicker").css("top", top);
});
0reactions
PeterSawyercommented, Jul 23, 2016

Yep @fernandowalla is correct, for some reason my body had margin-top instead of padding-top for my fixed nav.

Fixed with this: -

body { padding-top: 60px; }

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap Datepicker: Misaligned - Stack Overflow
What's the easiest work around? Adding a fixed top margin through javascript would work but is incredibly hacky. Is there a better solution?...
Read more >
Is there a way to center an embedded datepicker inside a <div>?
Problem is: it doesn't go to the center of its available space. A 50% padding-left goes way too far and adjustements do not...
Read more >
Input group - Bootstrap
Easily extend form controls by adding text, buttons, or button groups on either side of textual inputs, custom selects, and custom file inputs....
Read more >
Tables · Bootstrap v5.0
Due to the widespread use of <table> elements across third-party widgets like calendars and date pickers, Bootstrap's tables are opt-in.
Read more >
Forms - Bootstrap
If your form layout allows it, you can swap the .{valid|invalid}-feedback classes for .{valid|invalid}-tooltip classes to display validation feedback in a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found