0

I have this template on CodePen

I've really tried to customize it to show only minutes and seconds, but I couldn't.

What I'm missing?

My next step is add buttons to setup the minutes, pause and reset the countdown, how can I do that?

Thanks in advance!

HTML:

<body>

<div class="countdown countdown-container container">
    <div class="clock row">
        <div class="clock-item clock-days countdown-time-value col-sm-6 col-md-3" id="days">
            <div class="wrap">
                <div class="inner">
                    <div id="canvas-days" class="clock-canvas"></div>
                    <div class="text">
                        <p class="val">0</p>
                        <p class="type-days type-time">DAYS</p>
                    </div>
                    <!-- /.text -->
                </div>
                <!-- /.inner -->
            </div>
            <!-- /.wrap -->
        </div>
        <!-- /.clock-item -->
        <div class="clock-item clock-hours countdown-time-value col-sm-6 col-md-3">
            <div class="wrap">
                <div class="inner">
                    <div id="canvas-hours" class="clock-canvas"></div>
                    <div class="text">
                        <p class="val">0</p>
                        <p class="type-hours type-time">HOURS</p>
                    </div>
                    <!-- /.text -->
                </div>
                <!-- /.inner -->
            </div>
            <!-- /.wrap -->
        </div>
        <!-- /.clock-item -->
        <div class="clock-item clock-minutes countdown-time-value col-sm-6 col-md-3">
            <div class="wrap">
                <div class="inner">
                    <div id="canvas-minutes" class="clock-canvas"></div>
                    <div class="text">
                        <p class="val">0</p>
                        <p class="type-minutes type-time">MINUTES</p>
                    </div>
                    <!-- /.text -->
                </div>
                <!-- /.inner -->
            </div>
            <!-- /.wrap -->
        </div>
        <!-- /.clock-item -->
        <div class="clock-item clock-seconds countdown-time-value col-sm-6 col-md-3">
            <div class="wrap">
                <div class="inner">
                    <div id="canvas-seconds" class="clock-canvas"></div>
                    <div class="text">
                        <p class="val">0</p>
                        <p class="type-seconds type-time">SECONDS</p>
                    </div>
                    <!-- /.text -->
                </div>
                <!-- /.inner -->
            </div>
            <!-- /.wrap -->
        </div>
        <!-- /.clock-item -->
    </div>
    <!-- /.clock -->
</div>
<!-- /.countdown-wrapper -->

</body>

CSS:

html, body {
    height: 100%;
}
html {
    background-image: url('http://i.imgur.com/E7djQGn.jpg');
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
}
body {
    background-color: rgba(44,62,80 , 0.6 );
    background-image: url('http://i.imgur.com/AOEi9ts.png');
    background-position: center;
    background-repeat: repeat;
    font-family: 'Raleway', 'Arial', sans-serif;
}
.countdown-container {
    position: relative;
    top: 50%;
    -webkit-transform: translateY(-50%);
    -moz-transform: translateY(-50%);
    transform: translateY(-50%);
}
.clock-item .inner {
    height: 0px;
    padding-bottom: 100%;
    position: relative;
    width: 100%;
}
.clock-canvas {
    background-color: rgba(255, 255, 255, .1);
    border-radius: 50%;
    height: 0px;
    padding-bottom: 100%;
}
.text {
    color: #fff;
    font-size: 30px;
    font-weight: bold;
    margin-top: -50px;
    position: absolute;
    top: 50%;
    text-align: center;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 1);
    width: 100%;
}
.text .val {
    font-size: 50px;
}
.text .type-time {
    font-size: 20px;
}
@media (min-width: 768px) and (max-width: 991px) {
    .clock-item {
        margin-bottom: 30px;
    }
}
@media (max-width: 767px) {
    .clock-item {
        margin: 0px 30px 30px 30px;
    }
}

JS:

var today = new Date();
    // My target date is this month 30th 9.25pm
    var target = new Date(today);
    //target.setDate(2);
    target.setHours(21,25,0,0);

    // Countdown start from yesterday
    var yesterday = new Date(today);
    yesterday.setDate(today.getDate() - 1);
    yesterday.setHours(0,0,0,0);

    $('.countdown').final_countdown({
        'start': yesterday.getTime() / 1000,
        'end': target.getTime() / 1000,
        'now': today.getTime() / 1000,
        seconds: {
            borderColor: '#8ef58e',
            borderWidth: '0.5'
        },
        minutes: {
            borderColor: '#ff8d72',
            borderWidth: '0.5'
        },
        hours: {
            borderColor: '#69ccff',
            borderWidth: '0.5'
        },
        days: {
            borderColor: '#ffd35c',
            borderWidth: '0.5'
        }
    });
Ian Campelo
  • 163
  • 1
  • 3
  • 13

3 Answers3

0

Just delete the following two sections in the html and you'll be good to go:

<div class="clock-item clock-days countdown-time-value col-sm-6 col-md-3" id="days">
        <div class="wrap">
            <div class="inner">
                <div id="canvas-days" class="clock-canvas"></div>
                <div class="text">
                    <p class="val">0</p>
                    <p class="type-days type-time">DAYS</p>
                </div>
                <!-- /.text -->
            </div>
            <!-- /.inner -->
        </div>
        <!-- /.wrap -->
    </div>
    <!-- /.clock-item -->
    <div class="clock-item clock-hours countdown-time-value col-sm-6 col-md-3">
        <div class="wrap">
            <div class="inner">
                <div id="canvas-hours" class="clock-canvas"></div>
                <div class="text">
                    <p class="val">0</p>
                    <p class="type-hours type-time">HOURS</p>
                </div>
                <!-- /.text -->
            </div>
            <!-- /.inner -->
        </div>
        <!-- /.wrap -->
    </div>
    <!-- /.clock-item -->
Brian
  • 87
  • 10
0

Just set the class for the parts you don't want to display:none;

div.clock-hours { display:none; }
div.clock-days { display:none; }
JMJ
  • 99
  • 6
  • Unfornately the countdown stops to count if I do that – Ian Campelo Dec 03 '15 at 15:30
  • For the rest of it, i.e. increasing the timer you will need to get the current time, add your time to it, format it correctly and then re-init the timer using the new time. – JMJ Dec 03 '15 at 15:30
  • @IanCampelo Shove them off to the left then? `.clock-days { position:fixed; z-index:-1; left: -800px; }` `.clock-hours { position:fixed; z-index:-1; left: -800px; }` – JMJ Dec 03 '15 at 15:35
  • yeah! This way works. But how I align to the center, minutes and seconds? – Ian Campelo Dec 03 '15 at 15:49
  • @IanCampelo Since the other two are hidden, you can probably reduce the width of them to 1px, and add -1px margin to the visible ones, which should bring things back in line. – JMJ Dec 03 '15 at 15:53
  • @IanCampelo You might need to change the css of the parents a little. Shouldn't be too difficult. Wrap it all in a container and then just center that as you would with any other div. http://stackoverflow.com/a/10797328/5604868 – JMJ Dec 03 '15 at 16:20
  • Yeah! Like a charm! Thanks bro! – Ian Campelo Dec 03 '15 at 20:21
0

This worked for me after I added id="hours" to the hours div

#days { display:none }
#hours { display:none }
mplungjan
  • 169,008
  • 28
  • 173
  • 236