Bootstrap 4 Datepicker
Answer :
You can too override default datepicker classes like the following:
the default bootstrap font size is 1rem or 16px so update .datepicker class font-size: 0.875em;
or/and update the cell width and height:
.datepicker td, .datepicker th { width: 1.5em; height: 1.5em; }
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/css/bootstrap-datepicker.min.css" rel="stylesheet"/> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"></head> <body> <main class="container"> <div class="row" style="padding-top: 100px"> <div class="col"> <input data-date-format="dd/mm/yyyy" id="datepicker"> </div> </div> </main> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/js/bootstrap-datepicker.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> <style type="text/css"> // solution 1: .datepicker { font-size: 0.875em; } /* solution 2: the original datepicker use 20px so replace with the following:*/ .datepicker td, .datepicker th { width: 1.5em; height: 1.5em; } </style> <script type="text/javascript"> $('#datepicker').datepicker({ weekStart: 1, daysOfWeekHighlighted: "6,0", autoclose: true, todayHighlight: true, }); $('#datepicker').datepicker("setDate", new Date()); </script> </body>
From documentation:
bootstrap-datepicker.standalone.css
can be used to include the datepicker without depending on the Twitter Bootstrap library.
Comments
Post a Comment