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 URL's 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 it's URL and the proper URL extention.
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.
<!--<input type='button' value='HELP ME!!!' onclick='newWindowObj.open()'/>-->
<header>
<h1 id='title'>Weather Window</h1>
<p id='author'>Page Design by BenJam(In); <span id='credits'> Powered by openWeather</span></p>
</header>
<div class='d-flex justify-content-center'>
<div id='display'>
</div>
<div class='node1'>
<span class='span1'></span>
</div>
<div class='node2'>
<span id='cel' class='invisible'>C</span><span id='far'>F<span class='tiny'>push me</span></span>
</div>
<div class='node3'><span class='span2'></span>
</div>
</div>
body {
background-color: rgba(219, 214, 219, 0.39);
}
header{
position:fixed;
margin: 20px 0 0 20px;
text-align:center;
}
#title{
font-size:60px;
}
#credits{
font-size:10px;
}
#display {
width: 800px;
height: 500px;
border: 3px solid black;
margin: 100px 0;
border-radius: 50%;
position: fixed;
box-shadow: 10px 10px 10px black, -2px -2px 5px;
}
.node1 {
width: 300px;
height: 300px;
border: 4px solid black;
border-radius: 50%;
position: relative;
left: 470px;
top: 10px;
z-index: 10;
background-color: rgb(254, 252, 148);
color: black;
box-shadow: 5px 5px 10px black, -1px -1px 5px;
cursor: default;
}
.node2 {
width: 200px;
height: 200px;
border: 1px solid black;
border-radius: 50%;
position: relative;
left: -300px;
top: 400px;
z-index: 10;
background-color: rgb(254, 252, 148);
color: black;
box-shadow: 5px 5px 10px black, -1px -1px 5px;
cursor: pointer;
}
.node3 {
border: 1px solid black;
position: relative;
top: 430px;
left: 100px;
height: 100px;
border-radius: 50px;
padding: 10px 15px 20px 15px;
background-color: rgb(254, 252, 148);
color: black;
box-shadow: 5px 5px 10px black, -1px -1px 5px ;
cursor: default;
}
.span1 {
font-size: 120px;
position: relative;
top: 55px;
left: 65px;
}
.span2 {
font-size: 50px;
position: relative;
}
#cel,
#far {
font-size: 100px;
position: relative;
}
#cel {
top: 30px;
left: 62px;
}
#far {
top: 30px;
}
.invisible {
visibility: hidden;
}
.tiny {
font-size: 10px;
border: 1px solid black;
border-radius: 30px;
padding: 2px 4px;
background-color: white;
}
$(document).ready(function() {
//changed api for gathering location
var APIIP = "https://ipinfo.io/json";
//create new date
var hour = new Date().getHours();
//proxy server to get weather data - they dont offer https for free and Im not paying
var proxy = "https://cors-anywhere.herokuapp.com/";
//no need for this pop-up i fixed https issue for now
//will keep code for reference
/* var newWindowObj = window.open(
"",
"newWindow",
"width=500,height=150,top=100,left=100,toolbar=1,location=true,scrollbars=false,menubar=true,resizable=false,personalbar=true"
);
newWindowObj.document.write(
"<p style='background-color:red; border: 1px solid black;'>hello, if the weather isn't showing up....try deleting the -s- in https in the address bar. If that doesn't work open me up in debugged and that should do the trick. sorry for the inconvience.</p>"
); */
$.getJSON(
APIIP,
//requesting location data
function(data) {
//could do long and lat but would have to slice a string
//using city is a bit less specific but okay
var city = data.city;
var country = data.country;
//mandatory key for openweather api
var KEY = "&APPID=cdefd410530b3d8d178163965643440b";
//concat url with parameters and key code
var URL =
"http://api.openweathermap.org/data/2.5/weather?q=" +
city +
"," +
country +
KEY;
//requesting weather data
$.getJSON(proxy + URL, function(data) {
//isolate data and save to variables
var type = data.weather[0].main;
var id = data.weather[0].id;
var city = data.name;
//conversion formula
var tempCel = Math.round(data.main.temp - 273.15);
var tempC = tempCel + "°";
var weather = data.weather[0].description;
var tempF = Math.round(tempCel * (9 / 5) + 32) + "°";
//helps me see if i need to add more backgrounds more new ids
console.log(tempF);
console.log(id);
//setting data on page
$(".span1").text(tempF);
$(".span2").text(city);
//want to have one bg for night time
/*
if(hour > 5 || hour < 18){
$('#display').css("background-image", "url ('https://i.kinja-img.com/gawker-media/image/upload/s--EUYvNPnM--/c_scale,f_auto,fl_progressive,q_80,w_800/ke9svxml3ctkvgix59xl.jpg')");
}
*/
//if black for different types of weather id
//clear sky bg
if (id === 800 || id === 801) {
$("#display").css({
"background-image": "url('http://ak5.picdn.net/shutterstock/videos/1747219/thumb/1.jpg')",
"background-position": "-80px 10"
});
} else if (id <= 232 && id >= 200) {
//thunderstorm
$("#display").css({
"background-color": "black",
"background-image": "url('http://www.clker.com/cliparts/o/9/6/H/6/x/storm-cloud.svg')"
});
} else if (id < 532 && id >= 500) {
//rain bg
$("#display").css({
"background-image": "url('http://www.hartstoneinn.com/wp-content/uploads/2013/06/rainy_day.jpg')",
"background-position": "-200px 0"
});
} else if (id <= 622 && id >= 600) {
//snow bg
$("#display").css(
"background-image",
"url('http://uiconstock.com/wp-content/uploads/2014/03/Winter_Background.jpg')"
);
} else if (id <= 804 && id >= 802) {
//cloudy no rain bg
$("#display").css({
"background-color": "lightblue",
"background-image": "url('http://www.clipartbest.com/cliparts/ncE/BBb/ncEBBbMRi.png')",
"background-position": "-120px -190px"
});
} else if (id < 782 && id > 700) {
//foggy or hazy bg
$("#display").css({
"background-image": "url('http://clipground.com/images/fog-day-clipart-9.jpg')",
"background-size": "cover"
});
} else {
//default chicken cartoon bg
$("#display").css({
"background-image": "url('http://www.wpclipart.com/cartoon/animals/bird/bird_cartoons_2/confused_chickens.png')",
"background-position": "140px 50px"
});
}
//celcius farenheit toggle
$(".node2").on("click", function() {
$("#cel, #far").toggleClass("invisible");
if ($(".span1").text() === tempF) {
$(".span1").text(tempC);
} else {
$(".span1").html(tempF);
}
});
});
}
);
});
Also see: Tab Triggers