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.

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

<div id="condition2">
  <div>
    <p class="note note--two">Condition 2</p>
  </div>	
</div>
            
          
!
            
              body {
  background: Lavender;  
}

p {
  font-family: sans-serif;
  color: DarkSlateGrey;
}

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

#condition1 {
  background: IndianRed;
  border: 1px solid DarkRed;
}

#condition2 {
  background: LightSkyBlue;
  border: 1px solid DeepSkyBlue;
}

.note {
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  
  &--one {
    color: DarkRed;
  }
  
  &--two {
    color: Navy;
  }
}
            
          
!
            
              // 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);

// Print modified test date
document.write('<p>' + 'A day ago was: ' + '<strong>' + d.toLocaleString() + '</strong>'+ '</p>');

// Print date and time test of the start of our Date Range
document.write('<p>' + 'Start of date range is: ' + '<strong>' + minDate.toLocaleString() + '</strong>' + '</p>');

// Print date of the end of our Date Range
document.write('<p>' + 'End of date range is: ' + '<strong>' + maxDate.toLocaleString() + '</strong>' + '</p>');

// Print end of February of this year from the exception
document.write('<p>' + 'End of February this year is: ' + '<strong>' + maxDateException.toLocaleString() + '</strong>'+ '</p>');
            
          
!
999px
Loading ..................

Console