HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
.card
.detail
.circle
.apple-stuff
i.fa.fa-wifi
.time
|12:00 AM
i.fa.fa-battery-3.battery
.weather-forecast
.description
|WEATHER APP <br> <i class="fa fa-bolt"></i>
.city
.temp
.list
form.weather-form
input#city(placeholder="i.e. Detroit")
br
br
button(type="submit")
| Search Your City
@import bourbon
@import neat
$black: black
$white: #FAF7F5
$white2: rgba(255,255,255,0.9)
$gray: #9b9b9b
$blue1: #7FADAD
$yellow: #F4CD8B
+keyframes(container)
0%
perspective: 1000px
100%
perspective: 0px
+keyframes(card)
0%
+transform(rotateX(60deg) rotateY(-10deg) rotate(60deg) scale(1.05))
box-shadow: 0px 0px 20px 10px shade($yellow, 20%)
100%
+transform(rotateX(0deg) rotateY(0deg) rotate(0deg) scale(0.9))
box-shadow: 0px 0px 10px 4px shade($yellow, 10%)
html, body
font-family: Roboto
width: 100%
margin: 0
padding: 0
background: $yellow
perspective: 1000px
-webkit-animation-fill-mode: forwards
.card
height: 38em
width: 25em
margin: 0 auto
border-radius: 10px
margin-top: 1em
background: $blue1
box-shadow: 0px 0px 20px 10px shade($yellow, 20%)
overflow: hidden
position: relative
+animation(card 2s ease-in)
-webkit-animation-fill-mode: forwards
.detail
position: absolute
width: 100%
height: 65%
.circle
position: absolute
width: 35em
height: 16em
bottom: -51%
left: 50%
box-shadow: -2px -2px 9px shade($blue1, 7%)
+transform(translateX(-50%))
border-radius: 50%
background: $white
.apple-stuff
padding: 2% 2%
color: white
background: shade($blue1, 20%)
border-radius: 10px 10px 0px 0px
.time
display: inline
position: absolute
left: 50%
font-weight: 300
font-size: 0.8em
+transform(translateX(-50%))
.battery
margin-left: 21em
.weather-forecast
text-align: center
color: $white2
margin-top: 2em
+transition(0.3s)
.description
font-size: 2em
font-weight: 700
letter-spacing: 0.06em
position: relative
margin-top: 2px
i
font-size: 4em
margin-top: 0.3em
text-shadow: 5px 2px 2px yellow
.city
font-weight: 300
letter-spacing: 0.1em
margin-top: 0.5em
.temp
font-size: 6em
font-weight: 700
margin-top: 0.1em
.list
position: absolute
width: 100%
height: 35%
background: $white
bottom: 0
border-radius: 0px 0px 10px 10px
h3
.weather-form
text-align: center
margin-top: 5em
input
border: none
font-weight: 300
text-align: center
position: absolute
left: 50%
width: 100px
background: $white
+transform(translateX(-50%))
border-bottom: 3px solid rgba(0,0,0,0.2)
&:focus
outline: none
button
text-align: center
display: inline-block
padding: 0.4em 1em
font-size: 1em
position: absolute
left: 50%
+transform(translateX(-50%))
border: none
border-radius: 10px
letter-spacing: 2px
color: $white2
background: $blue1
width: 200px
+transition(0.2s)
&:hover
background: shade($blue1, 15%)
&:focus
outline: none
API_KEY='cfa56b61bd0276e5ba17b2062f7a808a'
ROOT_URL = "http://api.openweathermap.org/data/2.5/forecast?&appid=#{API_KEY}"
String.prototype.capitalizeFirstLetter = ->
return this.charAt(0).toUpperCase() + this.slice(1)
fetchWeather = (city) ->
url = "#{ROOT_URL}&q=#{city},us"
$.get(url, (data) ->
description = data.list[0].weather[0].description.capitalizeFirstLetter()
kalvin = data.list[0].main.temp
temp = Math.floor((kalvin - 273.15) * 1.8000 + 32.00 )
$(".description").html("#{description}")
$(".temp").html("#{temp}°F")
$(".city").html(data.city.name + ", United States")
)
$ ->
$('.weather-form').submit (e)->
city = $("input").val()
e.preventDefault()
fetchWeather("#{city}")
$("input").val('')
Also see: Tab Triggers