简体   繁体   中英

React Date Range Picker

I have a project am creating and I want to have a react-date-range calendar in the project. Problem is when displaying the calendar the dates are not aligned with the days. How can I[enter image description here align them properly.

Calendar Image

Calendar days and dates not aligned properly

react-date-range can be installed with npm , by the following command:

npm install react-date-range

First, styles and theme file must be imported:

import 'react-date-range/dist/styles.css'; // main css file
import 'react-date-range/dist/theme/default.css'; // theme css file

Then, import one of the 4 standalone components: DateRange , DateRangePicker , Calendar , DefinedRange

The best way is to follow documentation

make sure that you have the css imports in your code

import 'react-date-range/dist/styles.css';
import 'react-date-range/dist/theme/default.css'; 

Consider including this style; from what I recall, it's effective:

.react-datepicker__time-container   .react-datepicker__time  
.react-datepicker__time-box   ul.react-datepicker__time-list {  
     padding: 0; 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM