How layui's Calendar puts Monday in the first place


weeks

2:

1:

Thank you for answering my questions! Thank you! Thank you! Thank you!

Mar.23,2021

the official documentation does not say that this can be configured. It must be wrong for you to modify it.

< hr >

because the positioning of each date of each month in laydate is based on the first day, as long as the first day is set, this can be customized according to the weekly ranking. Since the default is code > index=0 , it should be adjusted according to the position of Sunday. For example, if Sunday is the last day of the week ( index=6 ), the setting is as follows:

//
    thisDate.setFullYear(dateTime.year, dateTime.month, 1);
startWeek = (thisDate.getDay()+6)%7;

of course, you can actually shoot strange calendar styles, such as Sunday in the middle ( index=3 )

//
    thisDate.setFullYear(dateTime.year, dateTime.month, 1);
startWeek = (thisDate.getDay()+3)%7;

after looking at the documentation, it seems that this configuration is not supported, and there is a creepy way to achieve it:

th, td {
  transform: translate(-100%);
}

th:first-child, td:first-child {
  transform: translateX(600%);
}

remember to add class, before to reduce the scope of influence.

Menu