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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console