Pen Settings

HTML

CSS

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.

+ 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

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.

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

              
                <body onload="loadCreditCard(); showGreeting();">
    <h1 class="title"> </h1>
    
    <div class="card">
        <div class="card-left-side">
            <div class="card-icon">
                <img src="http://www.freeiconspng.com/uploads/visa-icon-0.png" alt="Visa" />
            </div>
            <div class="card-total clear row">
                <label for="">Total</label>
                <p>£437.00</p>
            </div>        
            <div class="card-name-holder row">
                <label for="">Name</label>
                <p>Iulia</p>
            </div>
        </div>
        <div class="card-right-side">
            <div class="form-group">
                <label for="expiration-date">Expiration date</label>
                <span class="expiration-date" id="expiration-date"></span>
            </div>
            <form>
                <div class="form-group">
                    <label for="card-number">Card number</label>
                    <input type="tel" id="card-number" class="card-number" placeholder=""/><i class="icon remove-icon" id="remove-icon"></i>
                </div>            
                <div class="form-group">
                    <label for="security-code">Security code</label>
                    <span class="security-tooltip" aria-label="Enter the security code (CVV), the last 3 digits on the back of your card" tabindex="0"></span>
                    <input type="tel" name="security-code" class="security-code" onkeyup="trimCode(this)"/>
                    <p class="test" id="test">test</p>
                </div>
                <div class="validation">
                    <input type="checkbox" id="bubble">
                    <span class="tick"></span>
                </div>
            </form>
        </div>
    </div>
</body>
              
            
!

CSS

              
                // variables
$dark-blue: #b9c5c8;
$light-blue: #28455d;
$light-grey: #dce4e6;
$dark-grey: #406585;
$dark: #000;
$white: #fff;

//mixins
@mixin border-radius($radius) {
    border-radius: $radius;
}

// align vetically
@mixin align-vertical($position) {
    position: $position;
    top: 50%;
    left: 50%;
    transform: translate3d(-50%, -50%, 0);
}

// Media queries
$break-small-portrait: 320px;
$break-medium-portrait: 480px;
$break-small-landscape: 750px;
$break-medium: 1024px;
$break-large: 1124px;

@mixin respond-to($media) {
    @if $media == small-phones {
        @media only screen and (min-width: $break-small-portrait) { @content; 
      }
    }

    @if $media == medium-phones {
        @media only screen and (min-width: $break-medium-portrait) and (max-width: $break-small-landscape) { @content; }
    }

    @if $media == phones {
        @media only screen and (min-width: $break-small-portrait) and (max-width: $break-small-landscape) { @content; }
    }

    @else if $media == tablets {
        @media only screen and (min-width: $break-small-landscape + 1) and (max-width: $break-medium - 1) { @content; }
    }

    @else if $media == tablets-landscape {
        @media only screen and (min-width: $break-small-landscape + 1) and (max-width: $break-medium) and (orientation: landscape) { @content; }
    }

    @else if $media == phones-tablets {
        @media only screen and (min-width: $break-small-portrait) and (max-width: $break-medium - 1) { @content; }
    }

    @else if $media == wide-screens {
        @media only screen and (min-width: $break-large) { @content; }
    }

    @else if $media == custom-phones-tablets {
        @media only screen and (min-width: $break-small-portrait) and (max-width: $break-medium) { @content; }
    }

   @else if $media == phone-landscape {
     @media only screen and (min-width: $break-small-portrait) and (max-width: 640px) and (orientation: landscape) { @content; }
    }

    @else if $media == mobile-only {
        @media only screen and (max-width: $break-small-landscape) { @content; }
    }
}

body {
    background: $light-grey;
    font-family: 'Open Sans', sans-serif;
    font-weight: 300;
}

h1 {
    text-align: center;
    margin: 0 auto;
    font-size: 28px;
    line-height: 20px;
    
    &.title {
        @include align-vertical(absolute);
        font-size: 30px;
        position: absolute;
        top: 20%;
        
    }
}

label {
    display: block;
    font-size: 16px;
    padding: 10px 0;
    text-transform: uppercase;
}

.card-number,
.security-code {
    @include border-radius(4px);
    background: none;
    border: 1px solid #e49c06;
    color: #fff;
    font: 300 20px/20px Open sans, sans-serif;
    height: 40px;
    outline: none;
    padding: 5px 10px;
    transition: all 250ms ease-in-out;
    letter-spacing: 2px;
    width: 90%;
}

input[type="text"]::after {
    content: '';
    color: #000;
    width: 20px;
    height: 20px;
    position: relative;
}

.icon::before {
    font-family: "FontAwesome";
}

.remove-icon::before {
    content: "x";
    font-family: Open Sans, sans-serif;
    color: #fff;
    margin: 0 0 0 -20px;
    font-weight: 300;
    font-size: 22px;
    cursor: pointer;
    opacity: 0.3;
}

.security-code {
    border: 1px solid #4a667c;
    float: left;
    height: 50px;
    margin: 0 10px 0 0;
    padding: 0 10px;
    text-align: center;
    width: 120px;
}

.security-code:focus {
    box-shadow: 0 0 0.6rem $dark-grey;
}

.form-group {
    margin: 20px 0;
}

.card {
    @include border-radius(10px);
    box-shadow: 0px 5px 25px #93a3a7;
    color: $light-grey;
    height: 400px;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
    transform: translateY(50%);
    top: 50%;
    width: 640px;
}

.card-left-side {
    background: linear-gradient($light-grey, $dark-blue);
    box-sizing: border-box;
    color: $dark;
    float: left;
    font-size: 20px;
    height: 100%;
    padding: 20px;
    position: relative;
    width: 40%;
    
    .card-icon {
        text-align: right;
        margin-bottom: 20px;

        img {
            width: 80px;
        }
    }
    
    .card-total,
    .card-name-holder {
        margin-top: 30px;
        
        p {
            font-size: 36px;
        }
    }
}

.clear {
    clear: both;
}

.row {
    margin: 20px 0;
}

.card-right-side {
    background: #28455d;
    box-sizing: border-box;
    float: left;
    height: 100%;
    padding: 0 0 0 10px;
    position: relative;
    width: 60%;
}

p.test {
    font-size: 30px;
    font-weight: 300;
    margin: 40px 0;
    opacity: 0.1;
    width: 100%;
    float: left;  
}

.validation {
    @include border-radius(100%);
    width: 30px;
    height: 30px;
    position: absolute;
    bottom: 128px;
    left: 160px;
    z-index: 800;
    
    #bubble:checked + span {
        // animation: toggle 2s 1;
        transform: translate3d(75%,-50%,0);
        background: #3CCC97;
    }
}

@keyframes toggle {
    0%   {
        transform:translate3d(-75%,-50%,0);
        border-right: 0 solid #BBBBBB;
        border-left: 0 solid #BBBBBB;
        background:#BBBBBB;
        border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%;
        height: 100px;
    }
    20% {
        border-right: 0 solid #BBBBBB;
        border-left: 0 solid #BBBBBB;
        border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%;
        transform:translate3d(-75%,-50%,0);
        height: 100px;
    } 
    40%  {
        border-left: 0 solid #BBBBBB;
        border-radius: 35% 65% 65% 35% / 50% 50% 50% 50%;
        height: 90px;
    }
    50%  {
        transform:translate3d(0%,-50%,0);
        border-right: 25px solid #BBBBBB;
        border-left: 0 solid #BBBBBB;
        background:#BBBBBB;
        border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%;
        height: 90px;   
    }
    75%  {
        border-left: 25px solid #3CCC97;
        border-color:#3CCC97;
        background: #3CCC97;
        border-radius: 65% 35% 35% 65% / 50% 50% 50% 50%;
        height: 90px;
    }
    100% {
        border-right: 0 solid #3CCC97;
        border-left: 0 solid #3CCC97;
        border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%;
        transform:translate3d(75%,-50%,0);
        height: 100px;
        width:100px
    }
}

.validation::before {
    @include border-radius(100%);
    content: '';
    position: absolute;
    top: 0;
    left: -5px;
    height: 40px;
    width: 40px;
    background-color: #243548;
    box-shadow: 20px 0 0 #243548, 50px 0 0 #243548;
}

.validation::after {
    content: '';
    background: #28455d;
    width: 30px;
    height: 30px;
    border-radius: 100%;
    position: absolute;
    top: -20px;
    left: 25px;
    box-shadow: 0 50px 0 #28455d;
}

.tick {
    @include border-radius(100%);
    @include align-vertical(absolute);
    background: #b9c5c8;
    width: 35px;
    height: 35px;  
    transform: translate3d(-50%, -35%, 0);
    // animation: toggle-reverse 2s 1;
    
    &:before, 
    &:after {
        // @include align-vertical(absolute);
        content: '';
        width: 2px;
        height: 18px;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(-45deg);
        display: inline-block;
        background: #dce4e6; 
        position: absolute;
    }
    
    &:after {
        transform: translate(-50%, -50%) rotate(45deg);
    }
}

@keyframes toggle-reverse {
    0%   {
        transform:translate3d(75%,-50%,0);
        background: #3CCC97;
        border-right: 0 solid #3CCC97;
        border-left: 0 solid #3CCC97;
        border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%;
        height: 100px;
    }
    20% {
        border-right: 0 solid #3CCC97;
        border-left: 0 solid #3CCC97;
        border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%;
        transform:translate3d(75%,-50%,0);
        height: 100px;
    } 
    40%  {
        border-right: 0 solid #3CCC97;
        border-radius: 65% 35% 35% 65% / 50% 50% 50% 50%;
        height: 90px;
    }
    50%  {
        transform:translate3d(0%,-50%,0);
        border-left: 25px solid #3CCC97;
        border-right: 0 solid #3CCC97;
        background: #3CCC97;
        border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%;
        height: 90px;   
    }
    75%  {
        border-right: 25px solid #BBBBBB;
        border-color:#BBBBBB;
        background:#BBBBBB;
        border-radius: 35% 65% 65% 35% / 50% 50% 50% 50%;
        height: 90px;
    }
    100% {
        border-right: 0 solid #BBBBBB;
        border-left: 0 solid #BBBBBB;
        border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%;
        transform:translate3d(-75%,-50%,0);
        height: 100px;
        width:100px
    }
}

.security-tooltip {
    position: relative;
    z-index: auto;
    font-family: 'Open Sans', sans-serif;
    
    &::before {
        // @include border-radius(100%);
        position: relative;
        color: #496074;
        top: -26px;
        left: -4px;
        font-family: "FontAwesome";
        content: '\f059';
        display: inline-block;
        width: 20px;
        height: 20px;
        outline: none;
    }
}

.security-tooltip:hover:before {
    width: 200px;
    height: 10px;
    padding: 10px;
    background: #537087;
    padding: 5px;
    content: attr(aria-label);
    cursor: pointer;
    outline: none;
    position: absolute;
    display: inline-table;
    border-radius: 10px;
    color: #fff;
    left: 150px;
    top: -80px;
    font-size: 14px;
    line-height: 18px;
    font-family: 'Open Sans', sans-serif;
}
              
            
!

JS

              
                // variables
var date = new Date();
var time = date.getHours(); //15
var year = date.getFullYear();
var month = date.getMonth();

var greetings = "What a nice day!"

// Ahaaa moment: value ==> input's VS innerHTML ==> div's
function showGreeting() {
    if (time > 0 && time < 12) {
        greetings = "Good morning";
    } else if (time >= 12) {
        greetings = "Good afternoon";
    } else {
        greetings = "Evening";
    }
    return greetings;
}

function loadCreditCard() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
     //{"name":"Iulia","number":4003914288280846,"type":"Visa", "securityCode":"123"}
        var creditCardContent = this.responseText;
        var elem = JSON.parse(creditCardContent);
        document.getElementById("test").innerHTML = elem.number + ' / ' + elem.securityCode;
    }
  };
  xhttp.open("GET", jsonUrl, true);
  xhttp.send();
}

var title = document.getElementsByClassName("title")[0];
title.innerHTML = showGreeting();

var exprDate = document.getElementsByClassName("expiration-date")[0];
var jsonUrl = "https://my-awesome-project-639be.firebaseio.com/credit-card.json";

//localstorage
// var cardNoPlaceholder = document.getElementById("card-number");
// var cardNo = localStorage.setItem("cardNumber", 4003914387702740);

// cardNoPlaceholder.setAttribute("placeholder", cardNo);

// if (itemListJson != "" && itemListJson != null) {
//   itemList = JSON.parse(itemListJson);
// }

exprDate.innerHTML = year + ' / ' + month;
//myString = myString.replace(/\D/g,'');

function trimCode(elems) {
    var numbersElem = document.querySelectorAll("input[type='tel']");
    
    for (var i = 0; i<=numbersElem.length; i++) {
        elems = numbersElem[i].value.replace(/\D/g, '');
        numbersElem[i].value = elems;
        console.log("There are: " + numbersElem.length);
    }
    return elems;
}

document.getElementById("remove-icon").onclick = function() {
    document.getElementById("card-number").value = "";
}
              
            
!
999px

Console