bootstrap-datepicker icon indicating copy to clipboard operation
bootstrap-datepicker copied to clipboard

position error

Open happyshi0402 opened this issue 5 years ago • 3 comments

Expected behaviour

position error

Actual behaviour

picture is: 图片

Datepicker version used

ex. 1.8.0

Example code

bootstrap-datepicker.js line 673: var left = offset.left - appendOffset.left; left = left + window.screen.width/2 - document.body.clientWidth / 2 ; // add this

happyshi0402 avatar Mar 27 '19 08:03 happyshi0402

bootstrap-datepicker.js line 673: var left = offset.left - appendOffset.left; left = left + window.screen.width/2 - document.body.clientWidth / 2 ; // add this

图片

happyshi0402 avatar Mar 27 '19 08:03 happyshi0402

I had a similar issue where the popup was positioned wrong (on top and a bit to the side of the input element). The cause appeared to be that I had margins on my body element, which caused everything to be shifted by appendOffset, even though the offset itself appeared to be absolute...

Your suggested solution worked if my window was maximized (where window.screen.width and document.body.clientWidth, and the same for heights, were fairly similar in size), but on a smaller window I would get weird offsets again.

Removing the margins from my body element fully resolved this for me.

vlumi avatar May 22 '19 03:05 vlumi

I had max-width and margin on body as well and therefore the wrong positioning. If you can, wrap everything in some <div id='mainContainer'> and apply the max-width and margin in this div. Works like a charm.

hansmaulwurf23 avatar Sep 26 '20 06:09 hansmaulwurf23