Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">

  <div id="condition1" class="m-y-1">
    <div>
      <p class="note note--one">Condition 1</p>
    </div>
  </div>

  <div id="condition2" class="m-y-1">
    <div>
      <p class="note note--two">Condition 2</p>
    </div>	
  </div>
  
  <div id="dates" class="dates"></div>
  
</div>
              
            
!

CSS

              
                body {
  background: var(--set-color-base);  
}

p {
  font-family: var(--set-font-sans);
  color: var(--set-color-white);
}

#condition1, #condition2 {
  padding: 1em;
}

#condition1 {
  background: var(--set-color-secondary);
}

#condition2 {
  background: var(--set-color-primary-tint);
}

.note {
  font-weight: var(--set-font-weight-heavy);
  text-align: center;
  text-transform: uppercase;
  
  &--one {
    color: var(--set-color-base);
  }
  
  &--two {
    color: var(--set-color-base);
  }
}

.dates {
  p {
    color: var(--set-color-base-light);
  }
  
  &__data {
    font-family: var(--set-font-mono);
    color: var(--set-color-white);
  }
}
              
            
!

JS

              
                document.addEventListener("DOMContentLoaded", function(){
    cssPropWrite();
});

// Define our variables
// 
var testDate = new Date('10/31/2017, 4:00:00 PM');
var currentDate = new Date(); 
var currentYear = new Date().getFullYear(); 
var nextYear = new Date().getFullYear()+1; 
var minDate = new Date('10/31/' + currentYear + ', 4:00:00 PM'); 
var maxDate = new Date('03/01/' + nextYear);
var minDateException = new Date('01/01/' + currentYear); 
var maxDateException = new Date('03/01/' + currentYear); 

// Modify our maxDate and maxDateException variables 
// 
maxDate.setDate(maxDate.getDate() - 1);
maxDateException.setDate(maxDateException.getDate() - 1);

// Set our Date Range
// 
if (currentDate >= minDate && currentDate <= maxDate ){ 
  $("#condition1").show(); 
  $("#condition2").hide();  
} else if (currentDate >= minDateException && currentDate <= maxDateException ){ 
  $("#condition1").show(); 
  $("#condition2").hide(); 
} else { 
  $("#condition1").hide(); 
  $("#condition2").show(); 
}

// Test date modification
// 
var d = new Date();
// this modifies the date object and returns the time value of the updated date.
d.setDate(d.getDate() - 1);

// Write modified test date
// Write date and time test of the start of our Date Range
// Write date of the end of our Date Range
// Write end of February of this year from the exception
document.getElementById('dates').innerHTML ="<p>" + 'A day ago was: ' + '</br>' + '<div class="dates__data">' + d.toLocaleString() + '</div>'+ "</p>" + '<p>' + 'Start of date range is: ' + '</br>' + '<div class="dates__data">' + minDate.toLocaleString() + '</div>' + '</p>' + '<p>' + 'End of date range is: ' + '</br>' + '<div class="dates__data">' + maxDate.toLocaleString() + '</div>' + '</p>' + '<p>' + 'End of February this year is: ' + '</br>' + '<div class="dates__data">' + maxDateException.toLocaleString() + '</div>'+ '</p>';
  
function cssPropWrite() {
    document.documentElement.style
    .setProperty('--add-font-sans', 'Roboto');

    document.documentElement.style
    .setProperty('--add-font-serif', 'Merriweather');

    document.documentElement.style
    .setProperty('--add-font-mono', 'Cousine');
}
              
            
!
999px

Console