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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import or require. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.css"/>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.1/css/materialize.min.css">
        <link rel="stylesheet" href="index.css">
    </head>
    <body>
        <div class="container">
            <div class="row">
                <div class="col l2 m4 offset-l5 offset-m4 s6  offset-s3 center">
                     <div class="col l4 m4 hide-on-med-and-up s12 center">
                        <h4>TU PESO EN OTROS<br>PLANETAS</h4>
                    </div>
                    <input id = "weight" type="number" class="center" placeholder="Introduce tu peso" />
                </div>
            </div>
            <div class="row">
                <div class="col l12 m12 s12 planets">
                    <div class="col l4 m4 s12 mars center">
                        <div class="planet"></div>
                        <div class="weight center">
                            <p>Peso en Marte</p>
                            <span id="weightMars"></span>
                        </div>
                    </div>
                    <div class="col l4 m4 hide-on-small-only s12 center">
                        <h4>TU PESO EN OTROS<br>PLANETAS</h4>
                    </div>
                    <div class="col l4 m4 s12 neptune">
                        <div class="planet center"></div>
                        <div class="weight center">
                            <p>Peso en Neptuno</p>
                            <span id="weightNeptune"></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script src= "index.js"></script>
    </body>

            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Palanquin+Dark');


body{
    background: #0B1C22;
    font-family: 'Palanquin Dark', sans-serif;
    color: white;
}
.container{
    margin-top: 8%;
}
.planets .mars .planet{
    background: #C25447;
    box-shadow: inset -30px -30px 0px #bf4d3f;

}
.planets .neptune .planet{
    background: #4420B7;
    box-shadow: inset -30px -30px 0px #36198F;

}
.planet {
    margin: 0 auto;
    width: 200px;
    height: 200px;
    border-radius: 100%;
    position: relative;
}
.planets .mars .planet:before{
    background: #b4483c;
}
.planets .neptune .planet:before{
    background: #241160;
}
.planets .mars .planet:after{
    background: #b84a3d;
}
.mars{
    margin-bottom: 20px;
}
.planets .neptune .planet:after{
    background: #241160;
}
.planet:before {
    content: '';
    border-radius: 100%;
    width: 12%;
    height: 12%;
    display: block;
    margin: 10% 30%;
    position: absolute;
}
.planet:after {
    content: '';
    border-radius: 100%;
    width: 25%;
    height: 25%;
    display: block;
    margin: 50% 35%;
    position: absolute;
}

span{
    font-size: 20px;
}

@media only screen and (max-width: 993px){
    .planet {
        width: 100px;
        height: 100px;
    }
    h4{
        font-size: 14px !important;
    }
    .planet:after{
        width: 20%;
        height: 20%;
        margin: 46% 23%;
    }
    .planets .neptune .planet{
        box-shadow:  inset -15px -10px 0px #36198F;
    }    
    .planets .mars .planet{
        box-shadow:  inset -15px -10px 0px #bf4d3f;
    }
}
            
          
!
            
              var weight = document.getElementById('weight')
var neptuneWeight = document.getElementById('weightNeptune')
var marsWeight = document.getElementById('weightMars')


weight.addEventListener('keyup', function(e){
    neptuneWeight.innerHTML = planetWeight(weight.value, 'neptune') + 'kg'
    marsWeight.innerHTML = planetWeight(weight.value, 'mars') + 'kg'
})

function planetWeight(weight, planet){
    var neptuneG = 11.15
    var earthG = 9.9
    var marsG = 3.71
    return calculate(weight, planet)
    
    
    function calculate(weight, planet){
        if (planet === 'neptune') return ((parseInt(weight) / earthG) * neptuneG).toFixed(2)
        if (planet === 'mars') return ((parseInt(weight) / earthG) * marsG).toFixed(2)
    }
}


            
          
!
999px

Console