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")
head
title
| POP in Taipei
body
section.page.header-page
.text-vertical-center
h1
| 住在天龍國的子民們
h3
| 想知道附近有多少公有地嗎?
a(href="#about")
i.big.circular.green.double.angle.down.icon
section#about.about-page.page
.text-vertical-center
h1
| 什麼是公有地?
h3
| 我也不知道,但你可以從
a.big.ui.red.button(href="http://hackfoldr.org/POPonFire")
| 這裡
| 找到答案
a(href="#area")
i.big.circular.orange.double.angle.down.icon
section#area.area-page.page
.text-vertical-center
h1
| 最想知道哪一區?
.ui.selection.dropdown.choice-area
input(type="hidden", name="area")
.default.text
|
i.dropdown.icon
.menu
a.item(data-value='中正區')
| 中正區
a.item(data-value='大同區')
| 大同區
a.item(data-value='中山區')
| 中山區
a.item(data-value='萬華區')
| 萬華區
a.item(data-value='信義區')
| 信義區
a.item(data-value='松山區')
| 松山區
a.item(data-value='大安區')
| 大安區
a.item(data-value='南港區')
| 南港區
a.item(data-value='北投區')
| 北投區
a.item(data-value='內湖區')
| 內湖區
a.item(data-value='士林區')
| 士林區
a.item(data-value='文山區')
| 文山區
section#map.map-page.page
#map-canvas
.text-vertical-center.map-notice
h1
| 請選擇地區
footer
.ui.divided.horizontal.link.list
.item
| 資料來源:
a(href="http://data.g0v.tw")
| g0v零時資料中心
.item
| © 2014 公有地大行動
html,
body {
width: 100%;
height: 100%;
}
body {
font-family: Arial, Helvetica, sans-serif;
}
.text-vertical-center {
display: table-cell;
text-align: center;
vertical-align: middle;
}
.text-vertical-center h1 {
color: white;
margin: 0;
padding: 0;
font-size: 5em;
font-weight: 800;
}
.text-vertical-center h3 {
color: #EFEFEF;
padding: 50px;
font-size: 3em;
}
.page {
display: table;
position: relative;
width: 100%;
height: 100%;
background-color: #59ABE3;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
.header-page {
background-color: #59ABE3;
}
.about-page {
background-color: #65C6BB;
}
.area-page {
background-color: #F4B350;
}
.map-page {
background-color: #D2D7D3;
}
.choice-area {
margin: 30px;
width: 500px;
}
#map-canvas {
height: 100%;
margin: 0px;
padding: 0px;
width: 100%;
}
footer {
text-align: right;
padding: 20px 0;
}
var taipei =
{
"中正區": {
"lat": 25.0293008,
"lng": 121.5205833
},
"大同區": {
"lat": 25.0645027,
"lng": 121.513314
},
"中山區": {
"lat": 25.0685028,
"lng": 121.5456014
},
"萬華區": {
"lat": 25.0294936,
"lng": 121.4978838
},
"信義區": {
"lat": 25.0287142,
"lng": 121.5723162
},
"松山區": {
"lat": 25.0601727,
"lng": 121.5593073
},
"大安區": {
"lat": 25.0263074,
"lng": 121.543846
},
"南港區": {
"lat": 25.038392,
"lng": 121.6219879
},
"北投區": {
"lat": 25.1531486,
"lng": 121.5174287
},
"內湖區": {
"lat": 25.0835016,
"lng": 121.5903754
},
"士林區": {
"lat": 25.1347802,
"lng": 121.5324453
},
"文山區": {
"lat": 24.9880073,
"lng": 121.5752716
}
};
var showMap = function(area) {
var lat = taipei[area].lat;
var lng = taipei[area].lng;
var popinfo = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById('map-canvas'), {
zoom: 15,
scrollwheel: false,
center: {lat: lat, lng: lng}
});
map.data.loadGeoJson('https://poponfire.herokuapp.com/api/taipei/' + area);
// Set the stroke width, and fill color for each polygon
var featureStyle = {
fillColor: 'red',
strokeWeight: 1
};
map.data.setStyle(featureStyle);
map.data.addListener('click', function(event) {
var properties = ['面積', '路段', '地號', '管理者', '使用分區'];
var content = "<table class='ui table segment'>";
properties.forEach(function(element, index, array){
content += "<tr><td>"+ element + "</td><td>" + event.feature.getProperty(element) + "</td></tr>";
});
content += "</table>";
popinfo.close();
popinfo.setContent(content);
popinfo.setPosition(event.latLng);
popinfo.open(map);
});
};
(function(){
$('.dropdown').dropdown(
{
'onChange': function(val) {
$('.map-notice').hide();
showMap(val);
$("html, body").animate(
{ scrollTop: $(document).height()- $(window).height() }, "slow");
}
});
})();
Also see: Tab Triggers