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.
<!DOCTYPE html>
<html>
<head>
<title</title>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="IE=Edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<!-- Add references to the Azure Maps Map control JavaScript and CSS files. -->
<link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.css" type="text/css" />
<script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.js"></script>
<script type='text/javascript'>
var map, datasource, layout = 'symbol';
function GetMap() {
//Initialize a map instance.
map = new atlas.Map('myMap', {
view: 'Auto',
//Add your Azure Maps subscription client ID to the map SDK. Get an Azure Maps client ID at https://azure.com/maps
authOptions: {
authType: "anonymous",
clientId: "04ec075f-3827-4aed-9975-d56301a2d663", //Your Azure Active Directory client id for accessing your Azure Maps account
getToken: function (resolve, reject, map) {
//URL to your authentication service that retrieves an Azure Active Directory Token.
var tokenServiceUrl = "https://azuremapscodesamples.azurewebsites.net/Common/TokenService.ashx";
fetch(tokenServiceUrl).then(r => r.text()).then(token => resolve(token));
}
}
});
//Load template names into UI.
var templateNames = atlas.getAllImageTemplateNames();
var html = [];
for (var i = 0; i < templateNames.length; i++) {
if (i === 0) {
html.push('<option value="', templateNames[i], '" selected="selected">', templateNames[i], '</option>');
} else {
html.push('<option value="', templateNames[i], '">', templateNames[i], '</option>');
}
}
document.getElementById('TemplateNames').innerHTML = html.join('');
//Wait until the map resources are ready.
map.events.add('ready', function () {
map.controls.add(new atlas.control.StyleControl({mapStyles: 'all' }), {
position: 'top-right'
});
datasource = new atlas.source.DataSource();
map.sources.add(datasource);
map.layers.add([
//Add a polygon layer for rendering fill patterns.
new atlas.layer.PolygonLayer(datasource, null, {
fillPattern: 'myTemplatedIcon',
fillOpacity: 1,
filter: ['==', ['geometry-type'], 'Polygon']
}),
//Add a line layer for displaying the line.
new atlas.layer.LineLayer(datasource, null, {
strokeColor: 'Purple',
strokeWidth: 3,
filter: ['==', ['geometry-type'], 'LineString']
}),
//Add a symbol layer for rendering the arrow along the line.
new atlas.layer.SymbolLayer(datasource, null, {
lineSpacing: 50,
placement: 'line',
iconOptions: {
image: 'myTemplatedIcon',
allowOverlap: true,
anchor: 'center'
},
filter: ['==', ['geometry-type'], 'LineString']
}),
//Add a symbol layer for rendering images as symbols.
new atlas.layer.SymbolLayer(datasource, null, {
iconOptions: {
image: 'myTemplatedIcon',
allowOverlap: true,
ignorePlacement: true
},
filter: ['==', ['geometry-type'], 'Point']
})
]);
update();
});
}
function update(type) {
if (type) {
layout = type;
}
var color = document.getElementById('PrimaryColor').value;
var colorTransparent = document.getElementById('PrimaryColorTransparent').checked;
if (colorTransparent) {
color = 'transparent';
}
var sColor = document.getElementById('SecondaryColor').value;
var sColorTransparent = document.getElementById('SecondaryColorTransparent').checked;
if (sColorTransparent) {
sColor = 'transparent';
}
var scale = parseFloat(document.getElementById('Scale').value);
var templateName = getSelectValue('TemplateNames');
if (map.imageSprite.hasImage('myTemplatedIcon')) {
map.imageSprite.remove('myTemplatedIcon');
}
map.imageSprite.createFromTemplate('myTemplatedIcon', templateName, color, sColor, scale).then(function () {
//Reload the geometry to trigger a re-render.
switch (layout) {
case 'symbol':
datasource.setShapes([new atlas.data.Point([0, 0])]);
break;
case 'line':
datasource.setShapes([new atlas.data.LineString([[-50, -20], [0, 40], [50, -20]])]);
break;
case 'polygon':
datasource.setShapes([new atlas.data.Polygon([[[-50, -20], [0, 40], [50, -20], [-50, -20]]])]);
break;
}
});
}
function getSelectValue(id) {
var elm = document.getElementById(id);
return elm.options[elm.selectedIndex].value;
}
</script>
</head>
<body onload="GetMap()">
<div id="myMap" style="position:relative;width:100%;height:400px;"></div>
<div style="position:absolute;top:10px;left:10px;background-color:white;border-radius:10px;padding:10px;">
<table>
<tr title="The method in which to use the icons.">
<td>Layout:</td>
<td>
<input type="radio" name="layout" checked="checked" onclick="update('symbol')">Symbol icon<br>
<input type="radio" name="layout" onclick="update('line')">Line symbols<br>
<input type="radio" name="layout" onclick="update('polygon')">Polygon fill
</td>
</tr>
<tr title="The name of the template to use.">
<td>Template Name:</td>
<td>
<select id="TemplateNames" onchange="update()"></select>
</td>
</tr>
<tr title="The primary color for the template.">
<td>Primary Color:</td>
<td>
<input type="color" value="#1A73AA" id="PrimaryColor" onchange="update()" />
<input type="checkbox" id="PrimaryColorTransparent" onclick="update()" />Transparent
</td>
</tr>
<tr title="The secondary color for the template.">
<td>Secondary Color:</td>
<td>
<input type="color" value="#ffffff" id="SecondaryColor" onchange="update()" />
<input type="checkbox" id="SecondaryColorTransparent" onclick="update()" />Transparent
</td>
</tr>
<tr title="The amount to scale the icon template by.">
<td>Scale:</td>
<td>
<form oninput="o.value=Scale.value">
<input type="range" id="Scale" value="1" min="0.1" max="5" step="0.1" oninput="update()" onchange="update()" />
<output name="o" for="Scale">1</output>
</form>
</td>
</tr>
</table>
</div>
</body>
</html>
Also see: Tab Triggers