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.
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>CSUN PLACE GUESSER</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>CSUN PLACE GUESSER</h1>
</header>
<div id="container">
<div id="instructions">
<p>MAP Quiz. Please double click on the map, the location of: </p>
</div>
<div id="map"></div>
</div>
<footer>Copyright 2020.</footer>
<script src="Project11.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCvdVqAClhO9We98mxXCCu1v_y24kdvbM8&callback=initMap"
async defer></script>
</body>
</html>
* {
box-sizing: border-box;
}
body {
font-family: helvetica, arial, sans-serif;
margin: 25px;
}
main {
display:block;
height:175px;
}
header {
border-bottom: 1px solid black;
}
h1 {
font-weight: bold;
color: #000;
}
.bold {
font-weight: bold;
}
p {
max-width: 600px;
}
li {
margin-bottom: 5px;
}
footer {
padding-top: 25px;
border-top: 1px solid black;
}
footer a {
float:left;
margin:5px;
}
.pet-image {
height:250px;
}
.dashboard div {
display:block;
}
.pet-image-container {
float:left;
padding:10px;
}
.dashboard {
float:left;
padding:20px;
}
.button-container {
margin-top:20px;
}
.button-container button {
width: 100px;
margin-right: 10px;
text-align: center;
display: inline-block;
float: left;
font-size:15px;
background-color: #1e2835;
border-color: #404853;
cursor:pointer;
background-image: linear-gradient(to bottom,rgba(246,246,246,.1)0%,rgba(30,40,53,0)66%);
color: #fafafa;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#container {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 78%;
width: 60%;
float: right;
}
function initMap(){
const map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 34.23833238, lng: -118.523664572},
zoom: 16,//15.8,
gestureHandling: "none",
disableDefaultUI: true,
clickableIcons: false
});
map.addListener("dblclick", e => {
console.log("I just double clicked!!!", e);
const geoCoder = new google.maps.Geocoder();
geoCoder.geocode({latLng: e.latLng}, (results, status) => {
if (status = google.maps.GeocoderStatus.OK) {
console.log('results from geocode api: ', results)
}
})
var JacarandaHall = new google.maps.Marker({
position: 34.241, 118.528,
map: map,
title: none
});
map.addListener('center_changed', function() {
// 3 seconds after the center of the map has changed, pan back to the
// marker.
window.setTimeout(function() {
map.panTo(marker.getPosition());
}, 3000);
});
marker.addListener('click', function() {
var rectangle = new google.maps.Rectangle({
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35,
map: map,
bounds: {
north: 34.241,
south: 34.242,
east: -118.528,
west: -118.53
}
});
});
});
//generate list of possible CSUN locations
const listOfPlaces = ["Where is Bayramian Hall", "Where is the Student Recreation Center", "Where is Jacaranda Hall", "Where is Juniper Hall", "Where is Redwood Hall", "Where is Matador Bookstore"];
listOfPlaces.sort(() => 0.5 - Math.random());
const currentQuestions = listOfPlaces.slice(0, 5);
const currentQuestionIndex = 0;
console.log('five selected questions', currentQuestions);
document.getElementById("instructions").innerHTML += `<p>${currentQuestions[currentQuestionIndex]}</p>`;
}
/*
//generate list of possible CSUN locations
const listOfPlaces = ["Bayramian Hall", "Student Recreation Center", "Jacaranda Hall", "Juniper Hall", "Redwood Hall", "Matador Bookstore"];
//function for wrong answer
function makeRed(userAnswer) {
console.log("make red");
});
//turn the user answer on the map red
}
//function for right answer
function makeGreen(userAnswer){
console.log("make green");
//turn the user answer on the map green
}
//function to prompt user
function promptUser(userAnswer){
console.log("click on an object");
//ask user to double click on a place
//userAnswer.addEventListener("click", rightOrWrong(userAnswer);
const findPlace = listOfPlaces.find(place => place === userAnswer);
if(listOfPlaces[userAnswer].ondblclick()){
rightOrWrong(userAnswer);
}
}
var rightAnswers=0;
//function that determines if user is right or wrong
function rightOrWrong(userAnswer) {
if (userAnswer === correctAnswer) {
document.write(`<p>You got it right!!!<p>`);
//run jQuery function to make clicked place on google green
console.log("you got it right!");
makeRed();
rightAnswers++;
} else {
document.write(`<p>You got it wrong!!!</p>`);
//run jQuery function to make clicked place on google red
console.log("you get it wrong!");
makeGreen();
}
}
//for each place on the map
for (var i = 0; i < 5; i++){
//prompt user to click on a location
promptUser('');
//generate a correct answer to compare this to
let correctAnswer = listOfPlaces[(Math.random() * listOfPlaces.length()).floor()];
document.write(`<p>Click on the location of , ${correctAnswer}</p>`);
//some sort of event handler to let the user click on a location, then determine whether they were right or right or wrong
//based on that click
let userAnswer=document.getElementById("rightAnswer").addEventListener("click", rightOrWrong());
rightOrWrong(userAnswer);
document.write(`${rightAnswers}/5`);
document.log("script runs");
}
*/
Also see: Tab Triggers