1

https://i.stack.imgur.com/2yxhI.jpg
this is what it looks like at the moment. Id like it to be in the center of the screen if possible. here is the code for the datepicker part

    <div class="input-group" style="margin-left: 20px;">
     <div id="datepicker-container">
      <div id="datepicker-center">
       <input type="text" id="from" class="form-control" style="width: 180px"/>
       <input type="text" id="to" class="form-control" style="width: 180px"/>
      </div>
     </div>
    </div>  

and the JS

$(function () {
$("#from").datepicker({
    defaultDate: "+1w",
    changeMonth: true,
    numberOfMonths: 3,
    onClose: function (selectedDate) {
        $("#to").datepicker("option", "minDate", selectedDate);
    }
});
$("#to").datepicker({
    defaultDate: "+1w",
    changeMonth: true,
    numberOfMonths: 3,
    onClose: function (selectedDate) {
        $("#from").datepicker("option", "maxDate", selectedDate);
    }
});
});  

I was trying this CSS, but it doesnt work

 #datepicker-container{
text-align:center !important;
}
#datepicker-center{
display:inline-block !important;
margin:0 auto !important;
}

Cant get fiddle to run the datepicker. heres a link too the site. http://bbennett36.github.io/firstclass/bookatrip.html

2 Answers2

1

try overriding inline css with

.ui-datepicker{ left: 50% !important; margin-left: -25.5em !important;}

25.5em is the half of width of calendar container

0

you have fixed style left: 577.172px in your html:

<div id="ui-datepicker-div" class="ui-datepicker 
ui-widget ui-widget-content ui-helper-clearfix ui-corner-all 
ui-datepicker-multi ui-datepicker-multi-3" style="position: absolute;
top: 459px; left: 577.172px; display: block; z-index: 4; width: 51em;">
  • remove the left attribute from <html>
  • add

    #ui-datepicker-div{left: 50%; margin-left: -25.5em;}
    - either in css or html (as initially used)
    - use id's for css precedence
    - no need for !important

warkentien2
  • 969
  • 13
  • 20