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 class='container-fluid'>
  <div id='progress'></div>
  <div id='length'>
    <p class='titles'>Timer Length</p>
    <i class="fa fa-minus" aria-hidden="true" id="minusLength"></i>
    <p id="totalLength">25</p>
    <i class="fa fa-plus" aria-hidden="true" id="plusLength"></i>
  </div>
  <div id='breaks'>
    <p class='titles'>Break Length</p>
    <i class="fa fa-minus" aria-hidden="true" id="minusBreak"></i>
    <p id="totalBreak">5</p>
    <i class="fa fa-plus" aria-hidden="true" id="plusBreak"></i></div><br>

  <div id='controls'>
    <i class="fa fa-pause" aria-hidden="true" id="pause"></i>
    <i class="fa fa-play" aria-hidden="true" id="start"></i>
    <i class="fa fa-undo" aria-hidden="true" id="reset"></i>
  </div>
  <div id='timer'><p id='running'>25:00</p></div>
</div>
            
          
!
            
              * {
  padding: 0;
  margin: 0;
  height: 100%;
}

.fa, p {
  height: auto;
}

.fa {
  font-size: 1.5em;
}

p {
  color: #FFFFFF;
}

.container-fluid {
  background-color: #333333;
  text-align: center;
}

.titles {
  position: relative;
  top: -20px;
}

#minusLength, #minusBreak {
  position: absolute;
  left: -30px;
  top: 40px;
}

#plusLength, #plusBreak {
  position: absolute;
  left: 110px;
  top: 40px;
}

#totalLength, #totalBreak {
  margin-top: 22px;
}

#progress {
  background-color: #a3273b;
  z-index: 0;
  width: 100%;
  position: fixed;
  top: 100%;
  left: 0;
  opacity: 1;
  transition: 0.5s ease;
}

#length {
  height: 100px;
  width: 100px;
  background-color: #555555;
  color: #777777;
  display: inline-block;
  margin-top: 50px;
  margin-right: 70px;
  border-radius: 50%;
  position: relative;
  z-index: 2;
  box-shadow: 0 3px 10px 1px rgba(0,0,0,.48);
}

#breaks {
  height: 100px;
  width: 100px;
  background-color: #555555;
  color: #777777;
  display: inline-block;
  margin-top: 50px;
  margin-left: 70px;
  border-radius: 50%;
  position: relative;
  z-index; 2;
  box-shadow: 0 3px 10px 1px rgba(0,0,0,.48);
}

#controls {
  height: 50px;
  width: 150px;
  color: #777777;
  display: inline-block;
}

#controls i {
  margin: 10px;
}

#timer {
  height: 200px;
  width: 200px;
  background-color: #555555;
  color: #777777;
  border-radius: 50%;
  position: fixed;
  top: 250px;
  left: calc(50% - 100px);
  box-shadow: 0 9px 30px 3px rgba(0,0,0,.46);
}

#running {
  position: relative;
  height: 50px;
  width: 100px;
  top: 40%;
  left: calc(50% - 50px);
  font-size: 2em;
}

i:hover {
  cursor: pointer;
}
            
          
!
            
              var length = 25;
var breaks = 5;
var timerSec = 1500;
var breakSec = 300;
var display = "25:00";

$("#minusLength").click(function() {
  if (length >= 10){
    length -= 5;
  }
  display = length + ":00";
  $('#totalLength').html(length);
  $('#running').html(display);
})

$("#plusLength").click(function() {
  length += 5;
  display = length + ":00";
  $('#totalLength').html(length);
  $('#running').html(display);
})

$("#minusBreak").click(function() {
  if (breaks >= 2){
    breaks -= 1;
    breakSec -= 60;
  }
  $('#totalBreak').html(breaks);
})

$("#plusBreak").click(function() {
  breaks += 1;
  breakSec += 60;
  $('#totalBreak').html(breaks);
})

$("#pause").click(function() {
  clearInterval(secondRefresh);
})

$("#start").click(function() {
  timerSec = length * 60;
  getItStarted();
})

$("#reset").click(function() {
  stopTimer();
  timerSec = length * 60;
  display = length + ":00";
  $('#running').html(display);
})

function timer (time) { //time in seconds
  var minutes = Math.floor(time/60);
  var seconds = '';
  if (time%60 == 0){
    seconds = "00";
  } else if (time%60 > 0 && time%60 < 10) {
    seconds = "0" + time%60;
  } else {
    seconds = time%60;
  }
  display = minutes + ":" + seconds;
  $('#running').html(display);
}

var secondRefresh;

function getItStarted() {
  secondRefresh = setInterval(function(){ 
  timerSec--;
  timer(timerSec);
  backgroundUp(((timerSec/(length*60))*100));
  if (timerSec === 0){
    timerSec = breakSec;
    stopTimer();
    $('#progress').css('bottom', "0%");
    $('#progress').css('top', "auto");
    alert('Break time!');
    $('#progress').css('background-color', "#3978dd");
    takeAbreak();
  }
  }, 1000);
}

function takeAbreak() {
  secondRefresh = setInterval(function(){ 
  timerSec--;
  timer(timerSec);
  backgroundDown((100-((timerSec/(breaks*60))*100))*-1);
  if (timerSec == 0){
    stopTimer();
    $('#progress').css('top', "100%");
    $('#progress').css('bottom', "auto");
    alert('Break is over!');
    $('#progress').css('background-color', "#a3273b");
  }
  }, 1000);
}

function stopTimer() {
  clearInterval(secondRefresh);
}

function backgroundUp(perc) {
  $('#progress').css('top', perc + "%");
}

function backgroundDown(perc) {
  $('#progress').css('bottom', perc + "%");
}
            
          
!
999px
Loading ..................

Console