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.

Quick-add: + add another resource

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.

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>Laying Out Calendar Events</h1>
<p>This is a quick grid demo for laying out events for a calendar week. Requires <code>display:contents</code> so this'll only work in Chrome (if you have experimental features turned on) and Firefox. See <a href="https://caniuse.com/#feat=css-display-contents">Can I Use</a> for more.</p>
<p>Check out the <a href="https://www.youtube.com/watch?v=GD1IKgrWTgU&feature=youtu.be">accompanying YouTube video</a></p>

<p><strong>Added by James Finley:</strong> Switched from data attributes and attribute selectors to CSS Custom Properties (Variables).</p>

<div class="week">
  <div class="week-day">Sunday</div>
  <div class="week-day">Monday</div>
  <div class="week-day">Tuesday</div>
  <div class="week-day">Wednesday</div>
  <div class="week-day">Thursday</div>
  <div class="week-day">Friday</div>
  <div class="week-day">Saturday</div>  
</div>
<div class="week">
  <div class="day">
    <h3 class="day-label">1</h3>
    <div class="event event-start event-end" style="--span: 2">Class</div>
    <div class="event event-end">Interview</div>
  </div>
  <div class="day">
    <h3 class="day-label">2</h3>
    <div class="event event-start event-end" style="--span: 1">Dinner</div>
  </div>
  <div class="day">
    <h3 class="day-label">3</h3>
    <div class="event event-start event-end" style="--span: 2">School</div>
  </div>
  <div class="day">
    <h3 class="day-label">4</h3>
    <div class="event event-start" style="--span: 4">Meeting</div>
  </div>
  <div class="day">
    <h3 class="day-label">5</h3>
  </div>
  <div class="day">
    <h3 class="day-label">6</h3>
  </div>
  <div class="day">
    <h3 class="day-label">7</h3>
  </div>
</div>
            
          
!
            
              .week {
  display:grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-flow: dense;
  grid-gap: 2px 10px;
}

.day {
  display:contents;
  background-color: #DDD; /* if display contents, this won't color */
}
.day-label {
  grid-row-start: 1;
  text-align: right;
  margin:0;
}

.week-day, .day-label, .event {
  padding: 4px 10px;
}

.event {
  --span: 1;
  background-color: #CCC;
  grid-column-end: span var(--span);
}

.event-end { 
  border-top-right-radius: 10px; 
  border-bottom-right-radius: 10px; 
}

.event-start { 
  border-top-left-radius: 10px; 
  border-bottom-left-radius: 10px; 
}

.day:nth-child(1) > .event { grid-column-start: 1; }
.day:nth-child(2) > .event { grid-column-start: 2; }
.day:nth-child(3) > .event { grid-column-start: 3; }
.day:nth-child(4) > .event { grid-column-start: 4; }



/* other */
a { color: blue; }
            
          
!
999px
Loading ..................

Console