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.
<main>
<div class="inner">
<h2>
Pickup
</h2>
<h1>
Date & Time
</h1>
<form
id="date-and-time"
class="date-and-time"
method=""
>
<!-- Date -->
<span
class="date-wrapper select-wrapper faux-select"
>
<!-- Pickup Date - Select -->
<select
id="pickup-date-select"
class="pickup-date-select select faux-select"
data-placeholder-name="( Choose your pick up date )"
size="1"
>
<!-- Dynamically populate the date options,
adding Today, and 6 weeks into the future -->
</select>
<!-- Date - faux-select element,
can render inline or block -->
<a
id="date-rendered"
class="date-rendered faux-select-rendered"
tabindex="-1"
href="#"
>
<!-- Match the default DATE value here to the
default selected <option> element above -->
Today</a
>
</span>
<!-- / Date -->
<br/>
<!-- text -->
<span
class="text"
>
at
</span>
<!-- Time -->
<span
class="time-wrapper select-wrapper faux-select"
>
<!-- Pickup Time - Select -->
<select
id="time-select"
class="time-select select"
data-placeholder-name="( Choose your pick up time )"
size="1"
>
<!--
NOTE: ideal state would be
to populate the options
below dynamically with shop
hours for the specific date
the customer selects. Typically
this is governed by the day of
the week.
Hard coding for now.
Demo hours: 11:00 am - 11:00 pm
-->
<!-- Tool Tip, disabled option -->
<option
value=""
disabled
>
Choose your pick up time
</option>
<option disabled></option>
<option
value="11:00 am"
>11:00 am</option>
<option
value="11:15 am"
>11:15 am</option>
<option
value="11:30 am"
>11:30 am</option>
<option
value="11:45 am"
>11:45 am</option>
<option disabled></option>
<option
value="12:00 pm"
>12:00 pm</option>
<option
value="12:15 pm"
>12:15 pm</option>
<option
value="12:30 pm"
>12:30 pm</option>
<option
value="12:45 pm"
>12:45 pm</option>
<option disabled></option>
<option
value="1:00 pm"
>1:00 pm</option>
<option
value="1:15 pm"
>1:15 pm</option>
<option
value="1:30 pm"
>1:30 pm</option>
<option
value="1:45 pm"
>1:45 pm</option>
<option disabled></option>
<option
value="2:00 pm"
>2:00 pm</option>
<option
value="2:15 pm"
>2:15 pm</option>
<option
value="2:30 pm"
>2:30 pm</option>
<option
value="2:45 pm"
>2:45 pm</option>
<option disabled></option>
<option
value="3:00 pm"
>3:00 pm</option>
<option
value="3:15 pm"
>3:15 pm</option>
<option
value="3:30 pm"
>3:30 pm</option>
<option
value="3:45 pm"
>3:45 pm</option>
<option disabled></option>
<option
value="4:00 pm"
>4:00 pm</option>
<option
value="4:15 pm"
>4:15 pm</option>
<option
value="4:30 pm"
>4:30 pm</option>
<option
value="4:45 pm"
>4:45 pm</option>
<option disabled></option>
<option
value="5:00 pm"
selected
>5:00 pm</option>
<option
value="5:15 pm"
>5:15 pm</option>
<option
value="5:30 pm"
>5:30 pm</option>
<option
value="5:45 pm"
>5:45 pm</option>
<option disabled></option>
<option
value="6:00 pm"
>6:00 pm</option>
<option
value="6:15 pm"
>6:15 pm</option>
<option
value="6:30 pm"
>6:30 pm</option>
<option
value="6:45 pm"
>6:45 pm</option>
<option disabled></option>
<option
value="7:00 pm"
>7:00 pm</option>
<option
value="7:15 pm"
>7:15 pm</option>
<option
value="7:30 pm"
>7:30 pm</option>
<option
value="7:45 pm"
>7:45 pm</option>
<option disabled></option>
<option
value="8:00 pm"
>8:00 pm</option>
<option
value="8:15 pm"
>8:15 pm</option>
<option
value="8:30 pm"
>8:30 pm</option>
<option
value="8:45 pm"
>8:45 pm</option>
<option disabled></option>
<option
value="9:00 pm"
>9:00 pm</option>
<option
value="9:15 pm"
>9:15 pm</option>
<option
value="9:30 pm"
>9:30 pm</option>
<option
value="9:45 pm"
>9:45 pm</option>
<option disabled></option>
<option
value="10:00 pm"
>10:00 pm</option>
<option
value="10:15 pm"
>10:15 pm</option>
<option
value="10:30 pm"
>10:30 pm</option>
<option
value="10:45 pm"
>10:45 pm</option>
<option disabled></option>
<option disabled>Shop closes at 11:00 pm</option>
</select>
<!-- TIME - faux-select element,
can render inline or block -->
<a
id="time-rendered"
class="time-rendered faux-select-rendered"
tabindex="-1"
href="#"
>
<!-- Match the default TIME value here to the
default selected <option> element above -->
5:00 pm</a
>
</span>
<!-- / Time -->
<div>
<a
href=""
class="bttn submit"
>
Next
</a>
</div>
</form>
</div>
</main>
@import url('https://fonts.googleapis.com/css?family=Nunito:600,900|Shrikhand');
/*
font-family: 'Nunito', sans-serif;
font-family: 'Shrikhand', cursive;
*/
html,
body {
background: #1D3245;
font-family: 'Nunito', sans-serif;
font-weight: 600;
color: #DDF9FC;
}
body {
min-height: 100vh;
}
* {
box-sizing: border-box;
}
h1,
h2 {
margin: 0;
font-weight: normal;
}
a {
text-decoration: none;
}
main {
min-height: 100vh;
/* Vertical Centering main layout w/ Flexbox */
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-align-content: center;
-ms-flex-line-pack: center;
align-content: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
main > .inner {
max-width: 320px;
margin: 0 auto;
padding: 40px 16px;
text-align: center;
}
main h1 {
font-family: 'Shrikhand', cursive;
font-size: 28px;
line-height: 28px;
color: #DDF9FC;
}
main h2 {
display: inline-block;
font-family: 'Nunito', sans-serif;
font-weight: 900;
font-size: 10px;
line-height: 16px;
color: #DDF9FC;
text-transform: uppercase;
letter-spacing: 0.15em;
margin-bottom: 12px;
padding: 0 16px;
background: #0CB893;
border-radius: 500px;
}
form {
margin: 40px 0 0 0;
line-height: 44px;
}
form .text {
display: inline-block;
font-family: 'Shrikhand', cursive;
font-size: 28px;
font-weight: normal;
line-height: inherit;
color: #DDF9FC;
}
select,
input,
button {
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
-ms-appearance: none;
appearance: none;
}
.select-wrapper.faux-select {
display: inline-block;
vertical-align: bottom;
width: auto;
overflow: hidden;
line-height: inherit;
margin-left: 6px;
margin-bottom: -1px; /* nudge for baseline alignment with these fonts */
position: relative;
}
.select-wrapper select {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 10;
cursor: pointer;
opacity: 0.001;
/* opacity: 0.5; */
}
.faux-select-rendered {
position: relative;
z-index: 1;
pointer-events: none;
font-family: 'Nunito', sans-serif;
font-weight: 200;
font-size: 32px;
line-height: inherit;
color: #10F4C4;
}
.faux-select-rendered:after {
display: inline-block;
content: '▾';
text-indent: -9999em;
margin-left: 10px;
width: 11px;
line-height: inherit;
background: url(#) no-repeat center center transparent;
background-size: 11px 16px;
/* converting the custom arrow BG image into a data URI for this demo */
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDIxLjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9ImxheWVyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgMTEgMTYiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDExIDE2OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+Cgkuc3Qwe2ZpbGw6I0RDRjlGQzt9Cjwvc3R5bGU+CjxwYXRoIGlkPSJzZWxlY3QtYXJyb3dzIiBjbGFzcz0ic3QwIiBkPSJNNC44LDE1LjFMMC4zLDExYy0wLjQtMC40LTAuNC0xLDAtMS4zYzAuNC0wLjQsMS4xLTAuNCwxLjUsMGwzLjcsMy40bDMuNy0zLjQKCWMwLjQtMC40LDEuMS0wLjQsMS41LDBjMC40LDAuNCwwLjQsMSwwLDEuM2wtNC41LDQuMWMtMC4yLDAuMi0wLjUsMC4zLTAuNywwLjNTNSwxNS4zLDQuOCwxNS4xeiBNNC44LDAuNkwwLjMsNC43CgljLTAuNCwwLjQtMC40LDEsMCwxLjNjMC40LDAuNCwxLjEsMC40LDEuNSwwbDMuNy0zLjRsMy43LDMuNGMwLjQsMC40LDEuMSwwLjQsMS41LDBjMC40LTAuNCwwLjQtMSwwLTEuM0w2LjIsMC42CglDNiwwLjUsNS44LDAuNCw1LjUsMC40UzUsMC41LDQuOCwwLjZ6Ii8+Cjwvc3ZnPgo=);
/*border: 1px solid red;*/
}
.bttn {
display: inline-block;
font-family: 'Nunito', sans-serif;
font-weight: 600;
font-size: 16px;
line-height: 20px;
background-color: transparent;
color: #10F4C4;
padding: 9px 80px;
border-radius: 500px;
border: 2px solid #10F4C4;
}
.bttn.submit {
margin-top: 40px;
text-indent: -9999em;
background: url(#) no-repeat center center transparent;
background-size: 19px 14px;
/* Arrow SVG */
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDIxLjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9ImxheWVyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgMTkgMTQiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDE5IDE0OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+Cgkuc3Qwe2ZpbGw6IzEwRjRDNDt9Cjwvc3R5bGU+CjxwYXRoIGlkPSJhcnJvdy1yaWdodCIgY2xhc3M9InN0MCIgZD0iTTE4LjksN2MwLTAuMy0wLjEtMC41LTAuMy0wLjdsLTUuNi02Yy0wLjQtMC4zLTEuMS0wLjUtMS41LTAuMWMtMC40LDAuNC0wLjQsMS4xLDAsMS41CglsMy45LDQuMkgxQzAuNSw1LjksMCw2LjQsMCw3UzAuNSw4LDEsOGgxNC40bC0zLjksNC4yYy0wLjQsMC40LTAuNCwxLjEsMCwxLjVjMC40LDAuNCwxLjIsMC4zLDEuNS0wLjFsNS42LTYKCUMxOC44LDcuNSwxOC45LDcuMywxOC45LDdMMTguOSw3eiIvPgo8L3N2Zz4K);
}
// Dynamically populate the date
// <select> with options for a range
// of today through 6 weeks from now
function populate_date_select() {
var pickup_date_select = $("select.pickup-date-select");
// Using the Chicago Manual of Style
// abbreviations for day and month
// https://bit.ly/1JVilBm
var days = ["Sun", "Mon", "Tue", "Wed", "Thurs", "Fri", "Sat"];
var months = ["Jan.", "Feb.", "Mar.", "Apr.", "May", "June", "July", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."];
var dates = ["1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th", "21st", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th", "31st"];
var today = new Date().getTime();
var todaysDay = days[new Date().getDay()];
var todaysMonth = months[new Date().getMonth()];
var todaysDate = dates[new Date().getDate()] - 1;
// Add a disabled option at the start
$(pickup_date_select).append("<option disabled>Choose your pickup date</option><option disabled></option>");
// Options for today's date,
// using 'Today' instead of the date string
// NOTE: need to add the current date in the value attr
$(pickup_date_select).append("<option value='Today' selected>Today</option>");
var counter = 1;
var countUp = 24 * 60 * 60 * 1000;
// Counting up to 6 weeks (42 days)
for(counter; counter < 43; counter++) {
today = new Date(new Date().getTime() + (countUp * counter)).getTime();
todaysDay = days[new Date(new Date().getTime() + (countUp * counter)).getDay()];
todaysMonth = months[new Date(new Date().getTime() + (countUp * counter)).getMonth()];
todaysDate = dates[new Date(new Date().getTime() + (countUp * counter)).getDate() - 1];
$(pickup_date_select).append("<option value='" + todaysMonth + " " + todaysDate + "'>" + todaysDay + ", " + todaysMonth + " " + todaysDate + "</option>");
}
// Add a disabled option at the end,
// call instructions for further out
$(pickup_date_select).append("<option disabled></option><option disabled>Call to order at a later date.</option>");
// Add a break between weeks
// to make the list more scanable
var mondays = $( "option:contains('Mon')" );
$(mondays).before("<option disabled></option>");
}
populate_date_select();
function faux_select_update() {
// update the rendered value
// of any faux-select element when
// its paired real select changes
$('.faux-select select').change(function(){
var real_select = $(this);
var option_selected = $(this).find('option:selected').text();
var faux_select_rendered = $(this).siblings('.faux-select-rendered');
var faux_select_placeholder = $(this).attr("data-placeholder-name");
if( $(this).val() == ""){
$(faux_select_rendered).html(faux_select_placeholder);
} else {
$(faux_select_rendered).html(option_selected);
}
});
}
faux_select_update();
Also see: Tab Triggers