css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <nav>
  <a id=prev href=#>&lt;&lt;</a>
  <span id=desc></span>
  <a id=next href=#>&gt;&gt;</a>
</nav>

<div class=calheader>
  <div class=calday>Sunday</div>
  <div class=calday>Monday</div>
  <div class=calday>Tuesday</div>
  <div class=calday>Wednesday</div>
  <div class=calday>Thursday</div>
  <div class=calday>Friday</div>
  <div class=calday>Saturday</div>
</div>

<div class="calendar" id=calendar></div>
            
          
!
            
              // Everything related to the calendar layout is in this first section.

$cellwidth: (100% / 7);
$calbreak: 55em;
$calborder: #999;

@mixin day($dayOfWeek) {
  @media screen and (min-width: $calbreak) {
    &:first-child {
      margin-left: ($cellwidth * ($dayOfWeek - 1));
    }

    &:last-child {
      margin-right: ($cellwidth * (7 - $dayOfWeek));
    }
  }
}

* {
  box-sizing: border-box;
}

.sunday {
  @include day(1);
}
.monday {
  @include day(2);
}
.tuesday {
  @include day(3);
}
.wednesday {
  @include day(4);
}
.thursday {
  @include day(5);
}
.friday {
  @include day(6);
}
.saturday {
  @include day(7);
}

.calheader,
.calpast,
.emptyday {
  display: none;
}


.calday {
  width: 100%;
}

@media screen and (min-width: $calbreak) {
  .calendar,
  .calheader {
    display: flex;
    flex-flow: row wrap;
    justify-content: space-around;
  }

  .calpast,
  .emptyday {
    display: block;
  }

  .calday {
    width: $cellwidth;
    border: 1px solid $calborder;
    padding: 0.5em 3px;
  }
}


// The rest of the CSS is just styling the content within the calendar cells.

$calcell: #FFF;
$calbg: darken(#FFF, 25%);
$datebg: lighten(#000, 10%);
$datefg: darken(#FFF, 10%);
$calmargin: 0 0 1em 1em;
$calpadding: 3px;
$caldatemargin: 0 0 0.5em;
$dayspacing:  0;
$normal: #000;
$itemHeight: 1.75em;
$itemSize: 14px;
$calborder: #999;


.calday {
  margin: $dayspacing;
  background-color: $calcell;
  font-size: $itemSize;
  padding: 0;

  h4 {
    clear: both;
  }

  @media screen and (min-width: $calbreak) {
    padding: $calpadding;
  }
}


.calendar {
  margin-top: 1em;

  h4 {
    margin-bottom: 0;
    padding-bottom: 0;
    font-size: 100%;
    margin-top: 0;
    font-variant: small-caps;

    a {
      color: $normal;
      text-decoration: none;
      border: 0;
    }

    a:hover {
      color: #00F;
      text-decoration: underline;
    }
  }

  ul {
    margin-top: 0;
    margin-bottom: 5px;
  }

  td {
    background-color: #FFF;
    padding: 3px;
  }

  .calpast {
    background-color: #F0F0F0;
    color: #999;
  }

  .calfuture {
    background-color: #F0F0F0;
  }

  ul {
    padding: 0;
    margin-bottom: 1em;
    clear: both;
  }

  li {
    list-style: none;
    margin-bottom: 1em;
  }
}

.calpast {
  a {
    color: #999;
    text-decoration: none;
  }

  a:hover {
    color: $normal;
    text-decoration: underline;
  }
}


.caldate {
  display: block;
  background-color: $datebg;
  color: $datefg;
  width: auto;
  text-align: right;
  padding: $calpadding;

  @media screen and (min-width: $calbreak) {
    margin: $caldatemargin;
    border-radius: 50%;
    text-align: center;
    width: 2em;
  }
}

@media screen and (min-width: $calbreak) {
  .calheader {
    .calday {
      text-align: center;
      border: 0;
    }
  }

  .caldate {
    margin: $calmargin;
    float: right;
  }
}

div.calswitch {
  float: right;
  text-align: right;
}

.calsubmit {
  border: 1px solid black;
  background-color: #FFF;
  color: #00F;
  font-weight: bold;
  cursor: pointer;
  margin-top: 2px;
}

            
          
!
            
              const wdays = [
  'sunday',
  'monday',
  'tuesday',
  'wednesday',
  'thursday',
  'friday',
  'saturday'
];


const months  = [
  'Jan',
  'Feb',
  'Mar',
  'Apr',
  'May',
  'Jun',
  'Jul',
  'Aug',
  'Sep',
  'Oct',
  'Nov',
  'Dec'
];


const today = new Date();
const cal = document.getElementById('calendar');

showCal();

function showCal() {
  let dayOfMonth = 1;
  const month = today.getMonth();
  let date = new Date();
  date.setDate(dayOfMonth);
  date.setMonth(month);
  date.setFullYear(today.getFullYear());
  
  cal.innerHTML = '';

  const dateStr = `${months[date.getMonth()]} ${date.getFullYear()}`;
  document.getElementById('desc').innerHTML = dateStr;

  while (date.getMonth() === month) {
    const wday = wdays[date.getDay()];
    
    const wordCount = Math.floor(Math.random() * 5);
    let className = `calday ${wday}`;
    
    if (! wordCount) {
      className += ' emptyday';
    }
    
    let html = `<span class=caldate>${dayOfMonth}</span><ul>` +
        "<li>words</li>".repeat(wordCount) +
        '</ul>';
    
    const div = document.createElement('div');
    div.innerHTML = html;
    div.className = className;
    cal.appendChild(div);
    
    ++dayOfMonth;
    date.setDate(dayOfMonth);
  }
}

function addMonth(event, count) {
  event.stopPropagation();
  event.preventDefault();
  
  // If you were on January 31st and added a month, you'd end up in March,
  // since there's no February 31st. So we reset to the first of the month.
  today.setDate(1);
  today.setMonth(today.getMonth() + count);
  showCal();
}

document.getElementById('prev').onclick = (e) => {
  addMonth(e, -1);
};

document.getElementById('next').onclick = (e) => {
  addMonth(e, 1);
};
            
          
!
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