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 esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM 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.
<div class="exposure-calculator">
<h1 class="exposure-page-title">Exposure Calculator</h1>
<div class="exposure-property-holder">
<div id="aperture" class="exposure-property">
<h3 class="exposure-property-title">Aperture Value:</h3>
<select name="aperture-value" id="aperture-value">
<option value="1" class="full-stop">f/1</option>
<option value="1.122" class="third-stop">f/1.1</option>
<option value="1.26" class="third-stop">f/1.2</option>
<option value="1.414" class="full-stop">f/1.4</option>
<option value="1.587" class="third-stop">f/1.6</option>
<option value="1.782" class="third-stop">f/1.8</option>
<option value="2" class="full-stop">f/2</option>
<option value="2.245" class="third-stop">f/2.2</option>
<option value="2.52" class="third-stop">f/2.5</option>
<option value="2.828" class="full-stop">f/2.8</option>
<option value="3.175" class="third-stop">f/3.2</option>
<option value="3.564" class="third-stop">f/3.5</option>
<option value="4" class="full-stop">f/4</option>
<option value="4.49" class="third-stop">f/4.5</option>
<option value="5.04" class="third-stop">f/5.0</option>
<option value="5.657" class="full-stop">f/5.6</option>
<option value="6.35" class="third-stop">f/6.3</option>
<option value="7.127" class="third-stop">f/7.1</option>
<option value="8" class="full-stop">f/8</option>
<option value="8.98" class="third-stop">f/9</option>
<option value="10.079" class="third-stop">f/10</option>
<option value="11.314" class="full-stop" selected="">f/11</option>
<option value="12.699" class="third-stop">f/13</option>
<option value="14.254" class="third-stop">f/14</option>
<option value="16.0" class="full-stop">f/16</option>
<option value="17.959" class="third-stop">f/18</option>
<option value="20.159" class="third-stop">f/20</option>
<option value="22.627" class="full-stop">f/22</option>
<option value="25.398" class="third-stop">f/25</option>
<option value="28.509" class="third-stop">f/28</option>
<option value="32" class="full-stop">f/32</option>
<option value="35.919" class="third-stop">f/36</option>
<option value="40.318" class="third-stop">f/40</option>
<option value="45.255" class="full-stop">f/45</option>
<option value="50.797" class="third-stop">f/50</option>
<option value="57.018" class="third-stop">f/57</option>
<option value="64" class="full-stop">f/64</option>
<option value="71.838" class="third-stop">f/72</option>
<option value="80.635" class="third-stop">f/80</option>
<option value="90.51" class="full-stop">f/90</option>
</select>
</div>
<div id="shutterSpeed" class="exposure-property">
<h3 class="exposure-property-title">Shutter Speed:</h3>
<select name="shutterSpeed-value" id="shutterSpeed-value">
<option value="0.0001221" class="full-stop">1/8000</option>
<option value="0.0001538" class="third-stop">1/6400</option>
<option value="0.0001938" class="third-stop">1/5000</option>
<option value="0.0002441" class="full-stop">1/4000</option>
<option value="0.0003076" class="third-stop">1/3200</option>
<option value="0.0003875" class="third-stop">1/2500</option>
<option value="0.00048828" class="full-stop">1/2000</option>
<option value="0.0006152" class="third-stop">1/1600</option>
<option value="0.0007751" class="third-stop">1/1250</option>
<option value="0.0009766" class="full-stop">1/1000</option>
<option value="0.0012304" class="third-stop">1/800</option>
<option value="0.0015502" class="third-stop">1/640</option>
<option value="0.0019531" class="full-stop">1/500</option>
<option value="0.0024608" class="third-stop">1/400</option>
<option value="0.0031004" class="third-stop">1/320</option>
<option value="0.0039063" class="full-stop">1/250</option>
<option value="0.0049216" class="third-stop">1/200</option>
<option value="0.0062008" class="third-stop">1/160</option>
<option value="0.0078125" class="full-stop" selected="">1/125</option>
<option value="0.0098431" class="third-stop">1/100</option>
<option value="0.0124016" class="third-stop">1/80</option>
<option value="0.015625" class="full-stop">1/60</option>
<option value="0.0196863" class="third-stop">1/50</option>
<option value="0.0248031" class="third-stop">1/40</option>
<option value="0.03125" class="full-stop">1/30</option>
<option value="0.0393725" class="third-stop">1/25</option>
<option value="0.0496063" class="third-stop">1/20</option>
<option value="0.0625" class="full-stop">1/15</option>
<option value="0.0787451" class="third-stop">1/13</option>
<option value="0.0992126" class="third-stop">1/10</option>
<option value="0.125" class="full-stop">1/8</option>
<option value="0.1574901" class="third-stop">1/6</option>
<option value="0.1984251" class="third-stop">1/5</option>
<option value="0.25" class="full-stop">1/4</option>
<option value="0.3149803" class="third-stop">1/3</option>
<option value="0.3968503" class="third-stop">1/2.5</option>
<option value="0.5" class="full-stop">1/2</option>
<option value="0.6299605" class="third-stop">1/1.6</option>
<option value="0.7937005" class="third-stop">1/1.3</option>
<option value="1.0" class="full-stop">1 second</option>
<option value="1.2599" class="third-stop">1.3"</option>
<option value="1.5874" class="third-stop">1.6"</option>
<option value="2" class="full-stop">2"</option>
<option value="2.5198" class="third-stop">2.5"</option>
<option value="3.1748" class="third-stop">3"</option>
<option value="4" class="full-stop">4"</option>
<option value="5.0397" class="third-stop">5"</option>
<option value="6.3496" class="third-stop">6"</option>
<option value="8" class="full-stop">8"</option>
<option value="10.0794" class="third-stop">10"</option>
<option value="12.6992" class="third-stop">13"</option>
<option value="16" class="full-stop">16"</option>
<option value="20.1587" class="third-stop">20"</option>
<option value="25.3984" class="third-stop">25"</option>
<option value="32" class="full-stop">30"</option>
<option value="40.3174" class="third-stop">40"</option>
<option value="50.7968" class="third-stop">50"</option>
<option value="64" class="full-stop">60"</option>
</select>
</div>
<div id="iso" class="exposure-property">
<h3 class="exposure-property-title">ISO:</h3>
<select name="iso-value" id="iso-value">
<option value="6.25/6" class="full-stop">6</option>
<option value="7.875/8" class="third-stop">8</option>
<option value="9.921/10" class="third-stop">10</option>
<option value="12.5/12" class="full-stop">12</option>
<option value="15.749/16" class="third-stop">16</option>
<option value="19.843/20" class="third-stop">20</option>
<option value="25/25" class="full-stop">25</option>
<option value="31.498/32" class="third-stop">32</option>
<option value="39.685/40" class="third-stop">40</option>
<option value="50/50" class="full-stop">50</option>
<option value="62.996/64" class="third-stop">64</option>
<option value="79.37/80" class="third-stop">80</option>
<option value="100/100" class="full-stop" selected="">100</option>
<option value="125.992/125" class="third-stop">125</option>
<option value="158.74/160" class="third-stop">160</option>
<option value="200/200" class="full-stop">200</option>
<option value="251.984/250" class="third-stop">250</option>
<option value="317.48/320" class="third-stop">320</option>
<option value="400/400" class="full-stop">400</option>
<option value="503.968/500" class="third-stop">500</option>
<option value="634.96/640" class="third-stop">640</option>
<option value="800/800" class="full-stop">800</option>
<option value="1007.937/1000" class="third-stop">1000</option>
<option value="1269.921/1250" class="third-stop">1250</option>
<option value="1600/1600" class="full-stop">1600</option>
<option value="2015.874/2000" class="third-stop">2000</option>
<option value="2539.841/2500" class="third-stop">2500</option>
<option value="3200/3200" class="full-stop">3200</option>
<option value="4031.747/4000" class="third-stop">4000</option>
<option value="5079.683/5000" class="third-stop">5000</option>
<option value="6400/6400" class="full-stop">6400</option>
<option value="8063.494/8000" class="third-stop">8000</option>
<option value="10159.366/10000" class="third-stop">10000</option>
<option value="12800/12800" class="full-stop">12800</option>
<option value="16126.989/16000" class="third-stop">16000</option>
<option value="20318.7/20000" class="third-stop">20000</option>
<option value="25600/25600" class="full-stop">25600</option>
<option value="32254/32000" class="third-stop">32000</option>
<option value="40637/40000" class="third-stop">40000</option>
<option value="51200/51200" class="full-stop">51200</option>
<option value="64508/64000" class="third-stop">64000</option>
<option value="81275/80000" class="third-stop">80000</option>
<option value="102400/102400" class="full-stop">102400</option>
</select>
</div>
</div>
<button onclick="calculateExposure()" type="button" class="submitButton">Calculate Exposure Information »</button>
<div class="exposure-border"></div>
<div class="ev-holder">
<div class="equivalent-values">
<h3 class="exposure-property-title">Exposure Value:</h3>
<span id="exposure-value" class="exposure-value">-</span> EV
</div>
<div class="equivalent-values">
<h3 class="exposure-property-title">Light Value:</h3>
<span id="light-value" class="exposure-value">-</span> EV<sub id="light-value-iso"></sub>
</div>
</div>
<div class="actual-exposure-holder">
<h3 class="exposure-property-title">Actual Exposure Information: </h3>
<div class="actual-exposure-information">
<span class="exposure-value-title">Actual Aperture Value:</span>
<span class="exposure-value" id="actual-aperture-value"></span>
</div>
<div class="actual-exposure-information">
<span class="exposure-value-title">Actual ShutterSpeed:</span>
<span class="exposure-value" id="actual-shutterspeed-value"></span>
</div>
<div class="actual-exposure-information">
<span class="exposure-value-title">Actual ISO:</span>
<span class="exposure-value" id="actual-iso-value"></span>
</div>
</div>
<div class="camera-settings-holder">
<h3 class="exposure-property-title">Exposure Settings: </h3>
<div class="updated-exposure-information">
<span class="exposure-value-title">Aperture Value:</span>
<span class="exposure-value" id="camera-aperture-value"></span>
</div>
<div class="updated-exposure-information">
<span class="exposure-value-title">Shutter Speed:</span>
<span class="exposure-value" id="camera-shutterspeed-value"></span>
</div>
<div class="updated-exposure-information">
<span class="exposure-value-title">ISO:</span>
<span class="exposure-value" id="camera-iso-value"></span>
</div>
</div>
<div class="exposure-border"></div>
<div class="nd-filter-holder">
<div class="filter-strength-select">
<h3 class="exposure-property-title">Neutral Density Filter Strength:</h3>
<select name="ndFilter" id="ndFilter" onchange="calculateFilterExposure()">
<option value="0" class="" selected="">None </option>
<option value="1" class="">2x - ND 0.3</option>
<option value="2" class="">4x - ND 0.6</option>
<option value="3" class="">8x - ND 0.9</option>
<option value="6" class="">64x - ND 1.8</option>
<option value="10" class="">1000x - ND 3.0</option>
</select>
</div>
<h3 class="exposure-property-title">Filter blocks <span id="filter-values"></span> stops of light</h3>
<h3 class="exposure-property-title">Exposure Settings with Filter: </h3>
<div class="updated-exposure-information">
<span>Aperture Value:</span>
<span class="exposure-value" id="filtered-aperture-value"></span>
</div>
<div class="updated-exposure-information">
<span>Shutter Speed:</span>
<span class="exposure-value" id="filtered-shutterSpeed-value"></span>
</div>
<div class="updated-exposure-information">
<span>ISO:</span>
<span class="exposure-value" id="filtered-iso-value"></span>
</div>
</div>
</div>
html {
background-image: url("https://r0bsc0tt.com/wp-content/uploads/2016/12/bgimage.jpg");
font-family: Open Sans;
font-size: 16px;
margin: 0 2em;
word-wrap: break-word;
}
.exposure-calculator {
background-color: white;
border: 4px double black;
max-width: 50%;
margin: 0.75rem auto;
padding-left: 25px;
padding-right: 25px;
}
.exposure-page-title {
color: #69c;
font-size: 2.25rem;
font-weight: 900;
line-height: 1;
text-align: center;
text-shadow: 1px 1px black, 2px 2px black;
text-transform: uppercase;
}
.exposure-property {
display: block;
}
.exposure-property-title {
margin-bottom: .25em;
}
.exposure-property .exposure-property-title {
text-align: center;
}
.exposure-border {
border-style: double;
margin: 1em 0;
}
select {
background-color: #efefef;
font-size: 1.5em;
}
.full-stop {
background-color: #fff;
font-size: 1.0125em;
font-weight: 900;
}
.third-stop {
color: #333;
}
button {
margin-top: 1em;
}
.submitButton,
.ev-holder,
.actual-exposure-holder,
.exposure-settings-holder,
.actual-exposure-information,
.updated-exposure-information,
select {
width: 100%;
}
.submitButton {
font-size: 1.125em;
font-weight: 700;
height: 2.5em;
line-height: 1;
margin: 2em 0 1em;
}
.actual-exposure-holder,
.camera-settings-holder {
display: block;
}
.actual-exposure-holder .exposure-property-title,
.camera-settings-holder .exposure-property-title,
.nd-filter-holder .exposure-property-title {
font-size: 1em;
font-weight: 900;
text-align: center;
text-transform: uppercase;
}
.equivalent-values,
.actual-exposure-information span,
.updated-exposure-information span {
font-weight: 900;
line-height: 1;
}
.equivalent-values {
display: inline-block;
line-height: 1;
width: 48%;
}
.equivalent-values:nth-child(1) {}
.equivalent-values:nth-child(2) {
float: right;
margin-left: 1%;
text-align: right;
}
.exposure-value-title {
color: #666;
}
.exposure-value {
color: #6699cc;
font-size: 2em;
}
.actual-exposure-information,
.updated-exposure-information {
display: inline-block;
line-height: 1.5;
width: 32%;
}
.actual-exposure-information span,
.updated-exposure-information span {
display: block;
}
.actual-exposure-information:nth-child(3n+2),
.updated-exposure-information:nth-child(3n+2) {
float: left;
text-align: left;
}
.actual-exposure-information:nth-child(3n+0),
.updated-exposure-information:nth-child(3n+0) {
text-align: center;
}
.actual-exposure-information:nth-child(3n+1),
.updated-exposure-information:nth-child(3n+1) {
float: right;
text-align: right;
}
var exposureSettings = [];
var calculateExposure = function(exposureProperty) {
"use strict";
var getExposureValues = (function() {
// Loop through each element from ExposureProperties
for (var i = exposureProperties.length - 1; i >= 0; i--) {
//set current elements id in DOM to variable, then add option values to array
var currentExposureProperty = document.getElementById(exposureProperties[i] + "-value");
if (currentExposureProperty) {
var currentExposurePropertyName = exposureProperties[i];
var currentExposurePropertyIndex = currentExposureProperty.selectedIndex;
var currentExposurePropertySettingValue = currentExposureProperty.options[currentExposurePropertyIndex].text;
var currentExposurePropertyActualValue = currentExposureProperty.options[currentExposurePropertyIndex].value;
//add settings to array
exposureSettings[i] = [currentExposurePropertyName, currentExposurePropertySettingValue, currentExposurePropertyActualValue, currentExposurePropertyIndex, currentExposureProperty];
} else {
console.log(exposureProperties[i] + "-value" + " not found");
} //end if
} //end for
})();
//Append HTML for settings information
var addExposureSettingsHTML = (function() {
if (typeof exposureSettings[0] === "object") {
// Add Camera Exposure Settings
document.getElementById("camera-aperture-value").innerHTML = exposureSettings[0][1];
document.getElementById("camera-shutterspeed-value").innerHTML = exposureSettings[1][1];
document.getElementById("camera-iso-value").innerHTML = exposureSettings[2][1];
//Add Actual Exposure Settings
document.getElementById("actual-aperture-value").innerHTML = exposureSettings[0][2];
document.getElementById("actual-shutterspeed-value").innerHTML = exposureSettings[1][2];
document.getElementById("actual-iso-value").innerHTML = exposureSettings[2][2].split("/")[0];
}
})();
//Get Equivalent Exposure Value
var equivalentExposureValues = (function() {
if (typeof exposureSettings[0] === "object") {
// Equivalent Exposure is calculated using log2(aperture * apeture / shutterspeed)
var eev = Math.log2(Number(exposureSettings[0][2]) * Number(exposureSettings[0][2]) / Number(exposureSettings[1][2]));
// Light Value is calculated using (log2(aperture * apeture / shutterspeed)) + log2(iso / 100)
var light = Math.log2(Number(exposureSettings[2][2].split("/")[0]) / 100);
var lev = eev + light;
//Equivalent Exposure values as HTML
document.getElementById("exposure-value").innerHTML = eev.toFixed(2);
document.getElementById("light-value").innerHTML = lev.toFixed(2);
document.getElementById("light-value-iso").innerHTML = exposureSettings[2][1];
}
})();
}; // close calculateExposure
//Find shutter speed with filter
var calculateFilterExposure = function() {
//ND Filter Values
var ndFilter = document.getElementById("ndFilter");
var ndValue = ndFilter.selectedIndex;
var shutterSpeedCurrent = exposureSettings[1][1];
var shutterSpeedOption = exposureSettings[1][4].options[exposureSettings[1][3]];
if (ndValue === 1) {
var oneStop = exposureSettings[1][3];
oneStop = oneStop + 3;
document.getElementById("filtered-shutterSpeed-value").innerHTML = exposureSettings[1][4].options[oneStop].text;
} else if (ndValue === 2) {
var twoStop = exposureSettings[1][3];
twoStop = twoStop + 6;
document.getElementById("filtered-shutterSpeed-value").innerHTML = exposureSettings[1][4].options[twoStop].text;
} else if (ndValue === 3) {
var threeStop = exposureSettings[1][3];
threeStop = threeStop + 9;
document.getElementById("filtered-shutterSpeed-value").innerHTML = exposureSettings[1][4].options[threeStop].text;
} else if (ndValue === 4) {
var sixStop = exposureSettings[1][3];
sixStop = sixStop + 18;
document.getElementById("filtered-shutterSpeed-value").innerHTML = exposureSettings[1][4].options[sixStop].text;
} else if (ndValue === 5) {
var tenStop = exposureSettings[1][3];
tenStop = tenStop + 30;
document.getElementById("filtered-shutterSpeed-value").innerHTML = exposureSettings[1][4].options[tenStop].text;
} else {
document.getElementById("filtered-shutterSpeed-value").innerHTML = exposureSettings[1][1];
};
//console.log(ndFilter);
//console.log(ndValue);
document.getElementById("filter-values").innerHTML = ndFilter.options[ndValue].value;
document.getElementById("filtered-aperture-value").innerHTML = exposureSettings[0][1];
document.getElementById("filtered-iso-value").innerHTML = exposureSettings[2][1];
};
var exposureProperties = ["aperture", "shutterSpeed", "iso"];
calculateExposure(exposureProperties);
Also see: Tab Triggers