cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <h1 id="calendar-header"></h1>
<div class="calendar">
  <div class="days-of-week">
    <span class="day-block">Monday</span>
    <span class="day-block">Tuesday</span>
    <span class="day-block">Wednesday</span>
    <span class="day-block">Thursday</span>
    <span class="day-block">Friday</span>
    <span class="day-block">Saturday</span>
    <span class="day-block">Sunday</span>
  </div>
  <div id="days-of-month" class="days-of-month">
    <!-- We will add the days in the calendar here -->
  </div>
            
          
!
            
              $gray:                #cccccc;
$gray-light:          #eeeeee;
$main-color:          #0D8CB2;
$white:               #ffffff;
$day-block-gutter:    4px;
$day-number-size:     25px;
$breakopoint-width:   960px;
$breakpoint:          "(min-width:#{$breakopoint-width})" !default;
$calendar-width:      80%;
$day-block-width:     100%/7; 
$calendar-span-class: calendar-span !default;

@mixin slugs() {
  @for $i from 1 through 7 {
    .#{$calendar-span-class}-#{$i} {
      flex-basis: $day-block-width * $i;
      display: flex;
      background: transparent !important;
      .day-block-inner {
        $day-block-inner-basis: 100% / $i;
        flex-basis: $day-block-inner-basis;
        outline: $day-block-gutter solid white;
        outline-offset: -$day-block-gutter;
      }
    }
  }
}

body {
  font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; 
}

h1 {
  text-align: center;
  color: $main-color;
}
.calendar {
  width: 95%;
  margin: 0 auto;
  .days-of-week, .days-of-month {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    .day-block {
      flex-basis: 100%;
      text-align: center;
      box-sizing: border-box;
      margin-bottom: $day-block-gutter;
    }
  }
  .days-of-week {
    margin-bottom: 1em;
    display: none;
    .day-block {
      height: 30px;
      background: $main-color;
      color: $white;
      text-transform: uppercase;
      font-size: .8em;
      letter-spacing: .1em;
      line-height: 30px;
    }
  }
  .days-of-month {
    .day-block, .day-block-inner {
      background: $gray-light;
      display: flex;
      min-height: $day-number-size *2;
      flex-basis: 100%;
      &:nth-of-type(even) {
        background: darken($gray-light, 10%);
      }
      .number {
        color: $white;
        background: $main-color;
        display: block;
        height: 100%;
        width: $day-number-size * 2;
        font-size: 1em;
        line-height: $day-number-size * 2;
      }
    }
  }
  @media #{$breakpoint} {
    width: $calendar-width;
    .days-of-week, .days-of-month {
      display: flex;
      .day-block, .day-block-inner {
        justify-content: flex-end;
        flex-basis: $day-block-width;
        outline: $day-block-gutter solid white;
        outline-offset: -$day-block-gutter;
        margin-bottom: 0;
        .number {
          font-size: .8em;
          margin: $day-block-gutter;
          width: $day-number-size;
          height: $day-number-size;
          line-height: $day-number-size;
        }
      }
      @include slugs;
    }
    .days-of-month {
      .day-block, .day-block-inner {
        &:nth-of-type(even) {
          background: $gray-light;
        }
      }
    }
  }
}
            
          
!
            
              //JS is used only to generate the the calendar dates dynamically and not to create the layout or styles.

var now              = new Date();
var currentMonth     = now.getMonth()+1;
var month            = now.getMonth();
var currentYear      = now.getFullYear();
var daysInMonthCount = new Date(currentYear, currentMonth, 0).getDate();

// Getting the Name of the month for our header
var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
];
var currentMonthName = (monthNames[month]);

// Getting the day of the week the month starts
var firstDayOfMonth = new Date(currentYear + "-" + currentMonth + '-01').getDay();

// Creating a variable to attach the firstDayOfMonth variable to the calendar-span class that will take advantage of the flex-basis code
var calendarSpan = 'calendar-span-' + firstDayOfMonth;

// Adding the calendar header with the current month and year
var header = document.getElementById('calendar-header');
header.innerHTML = header.innerHTML + currentMonthName + " " + currentYear;

// Loop through all days in the month
for (i = 1; i <= daysInMonthCount; i++) {
  
  // Making a variable with the HTML code for all days in the month
  // I will insert the day in number to the span with class of number
    var daysCalendarBlock = '<span class="day-block">'+
                              '<span class="number">' + i + '</span>'+
                            '</span>';
    // Making a variable for the fist day day-block with the HTML code. 
    // I also have to include the calendarSpan variable that will move the day-block to the corresponding day in the calendar
    var firstDayofCalendarBlock = '<span class="day-block ' + calendarSpan + '">' +
                                    '<span class="day-block-inner">' +
                                      '<span class="number">' + i + '</span>'+
                                    '</span>' +
                                   '</span>';
  
    // Appending the firstDayOfCalendar variable to the first of the month
    if ( i === 1)  {
      var firstDayOfCalendar = document.getElementById('days-of-month');
      firstDayOfCalendar.insertAdjacentHTML('beforeend', firstDayofCalendarBlock);
    } else {
      // Appending the daysOfCalendar variable to the days of the month
      var daysOfCalendar = document.getElementById('days-of-month');
      daysOfCalendar.insertAdjacentHTML('beforeend', daysCalendarBlock);
    }
};


            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console