Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Add weekend day backgrounds

I’m using flatpicker calendar and want to make every weekend day’s background #7a73aa. Unfortunately flatpicker does not add a class to weekend day’s.

I’ve tried this with css but that’s not working:

.dayContainer span:nth-child(6n) {
  background: #7a73aa;
  font-size: 20px;
}

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Page source:

enter image description here

Any idea how I could do this with css?

>Solution :

You can replace 6n with 7n to highlight sundays. Then add a rule for 7n-1 to highlight saturdays :

flatpickr('#calendar', {
  "locale": {
    "firstDayOfWeek": 1 // start week on Monday
  }
});
.dayContainer > .flatpickr-day:nth-child(7n),
.dayContainer > .flatpickr-day:nth-child(7n-1) {
    background: #7a73aa;
    font-size: 20px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.5.1/flatpickr.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css" rel="stylesheet"/>
<input type="text" id="calendar">
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading